I've just written something to insert 10000 rows into a table for the purposes of load testing.
The data in each of the rows is the same and uninteresting.
I did it like this:
DECLARE @i int = 0
WHILE @i < 10000 BEGIN
exec blah.CreateBasicRow ;
SET @i = @i + 1
END
All create basic row does is fill out the not null columns with something valid.
It turns out this is very slow and it even seems to hang occasionally! What are my alternatives? Would it be better to write something to generate a long file with all the data repeated with fewer insert clauses? Are there any other options?
Update
A constraint is that this needs to be in a form that sqlcmd can deal with - our database versioning process produces sql files to be run by sqlcmd. So I could generate a patch file with the data in a different form but I couldn't use a different tool to insert the data.