Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
What does GO do in this script ... or why would you use it?
1> create table employee(2> ID int,3> name nvarchar (10),4> salary int,5> start_date datetime,6> city nvarchar (10),7> region char (1))8> GO1>2> insert into employee (ID, name, salary, start_date, city, region)3> values (1, 'Jason', 40420, '02/01/94', 'New York', 'W')4> GO(1 rows affected)...repeats inserts as above...
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2009-02-14 : 23:20:13
GO is the batch separator - an instruction that the set of T-SQL instructions preceding the GO command should be sent to the server.This means, for example, that the scope of a variable ends with the GO command.GO is not a T-SQL command. It is just a batch separator. You can change it if you like - in SQL 2005, in Management Studio, in Tools -> Options -> Query Execution.GO nnn can be used to indicate that the preceding batch should be executed nnn times. For example: