GO GO GO

The GO command since SQL Server 2005 takes a [count] argument which instructs the server to execute the batch preceding GO the specified number of times. I have never realised that until yesterday.

So instead of doing:

declare @i int
select @i = 0

while @i < 100
begin
    insert test default values
    select @i = @i + 1
end

I can just execute:

insert test default values
go 100

Simple and elegant.