Tuesday, January 4, 2011

GO Keyword with Integer Parameter

In SQL Server the keyword GO tells SQL Server to execute the preceding code as one batch. From SQL Server 2005 onwards we can specify the integer parameter with GO keyword which will loop the preceding statement.

Example





create table jugal
(
name varchar(100) default 'jugal shah'
)
-- below command will insert the default value two times as we have specified 2 as parameter
insert into jugal values(default)
go 2

-- below command will print 'Jugal Shah' 100 times as we have specified 100 as parameter
print 'jugal shah'
go 100

No comments:

Post a Comment