X

Subscribe To Our Mailing List

P.S I will never spam you...100% GUARANTEED!

Thursday, July 3, 2014

go keyword in sql server 2008


Till now we know that “GO” keyword been used as a batch separator(which is default configured). "GO" is not a statement but a command to the server to commit the current batch to the Database.You can not use "GO" inside a stored procedure. If you would try, the definition of the procedure will end there, and the rest will be a separate batch. 

 Now lets see what you can do with this keyword.

go keyword in sql server 2008












In the above query i am simply creating a temparory table and i am trying to use “GO” keyword which will execute the insert statement 3 times and adds the value “Test” into the column “Name” of @abhiTable.

Same thing if i try for Table Variable (Assuming you know the difference between Temporary Table and Table Variable) the same thing does not work because, SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO.

Hope this helps.


No comments:

Post a Comment

Comments Section