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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 GO

Author  Topic 

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-02-27 : 09:44:20
What's the meaning of GO in a script?

Using SP, function and trigger templates, GO seems a standard thing to put in there. When I use my simple procedures, a select, insert into, update, delete from, it seems to make no difference if I use GO or not.

Is it for things woth loops and cursors? I don't see a lot of BEGIN and END. How do these tie up?

Thanks

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-02-27 : 09:47:23
GO is used to separate a batch in a script.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-27 : 09:49:08
GO is used to indicate end of bunch of statments (or batch, in sql server terminology). You don't need it after every statement. When Query Analyzer encounters GO, it sends all statements upto GO statement to SQL Engine for processing.

One more thing, GO is specific to Query analyzer and not a keyword. You can customize it to even your name in Query Analyzer options. But it is convention to use GO.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

mikebird
Aged Yak Warrior

529 Posts

Posted - 2008-02-27 : 10:38:11
Do you mean that GO is like selecting a load of text at one time, seperately in Query Analyzer with the mouse and hitting F5? And when the whole thing is run with nobody present, the GO keeps things seperate for you?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-02-27 : 11:58:14
yes.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-28 : 02:23:04
http://msdn2.microsoft.com/en-us/library/ms188037.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -