Advice about INSERT statement performance in SQL Server <p>I need to generate random numbers in SQL Server and write these codes into the table. I used the SQL statement as follows:</p> <pre><code>while (select count(code) from tb_random) &lt;1000000 begin SET NOCOUNT ON declare @r int set @r = rand()*10000000 insert into tb_random values(@r) end </code></pre> <p>It takes over 20h to complete this query. Could you give me an idea to solve this performance problem?</p>