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.
| Author |
Topic |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2009-08-04 : 08:40:35
|
| Hello,I am creating the Tables, Constrains and Stored Procedures in this order on my database. I start with:USE MyDatabase;GOAnd then I have the code to create the Tables, Constraints and SP.Do I need to have GO after each Create Table or Alter Table (For Constraint), etc?I never know very well how to use GO.Usually i have USE as I mentioned or a GO at the end of all code.Thanks,Miguel |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-08-04 : 08:42:15
|
The parser will tell you. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-08-04 : 08:57:32
|
HiGO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.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. A Transact-SQL statement cannot occupy the same line as a GO command. However, the line can contain comments.USE Database;GODECLARE @MyMsg VARCHAR(50)SELECT @MyMsg = 'Hello, World.'GO -- @MyMsg is not valid after this GO ends the batch.-- Yields an error because @MyMsg not declared in this batch.PRINT @MyMsgGOSELECT @@VERSION;-- Yields an error: Must be EXEC sp_who if not first statement in -- batch.sp_whoGO -------------------------R..http://code.msdn.microsoft.com/SQLExamples/http://msdn.microsoft.com/hi-in/library/bb500155(en-us).aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-08-04 : 09:47:18
|
| also seehttp://sqlblogcasts.com/blogs/madhivanan/archive/tags/GO/default.aspx |
 |
|
|
|
|
|