The other answers are all great/correct (the main difference is whether the DestTable
exists already (INSERT
), or doesn't exist yet (SELECT ... INTO
))
You may prefer to use INSERT
(instead of SELECT ... INTO
), if you want to be able to COUNT(*)
the rows that have been inserted so far.
Using SELECT COUNT(*) ... WITH NOLOCK
is a simple/crude technique that may help you check the "progress" of the INSERT
; helpful if it's a long-running insert, as seen in this answer).
[If you use...]
INSERT DestTable SELECT ... FROM SrcTable
...then yourSELECT COUNT(*) from DestTable WITH (NOLOCK)
query would work.