Sometimes I need to populate a lot of data into a table. First run of a fact maybe, and on that occasion I could be dealing with millions of rows. The trick to do the quickly is to lock the table. There are caveats that I won’t discuss in the short post, but the example below shows the syntax

1
2
3
4
INSERT INTO dbo.MyTable WITH (TABLOCKX)
SELECT foo, bar
FROM dbo.foobar
;