Another use of GO command in SQL Server 2005
As you all know, GO command signals the end of the batch of T-SQL statements
However in SQL Server 2005, it is also used to execute set of commands for a specified number of times
Consider that you want to create a table that should have hundred random integer values. You can the methods like the ones specified in http://sqlblogcasts.com/blogs/madhivanan/archive/2007/10/10/generating-random-numbers-part-ii.aspx or a while loop. You can also use GO command by specifying how many times it should run
create
table #numbers(random_value int)
GO -- Signals the end of the batch
insert
into #numbers(random_value) Select cast(100000*rand() as int)
GO 100 -- Signals that the above statement should run for 100 times
select
random_value from #numbers
Now the table would have 100 random interger values