What's the meaning of semi-colon in transact-sql?
Use AdventureWorks; GO
What's the meaning of semi-colon after AdventureWorks? Is that to signa开发者_运维技巧l the end of the statement? In that case, what the point of having GO.
Thanks for helping
Here is an article on SQLServerCentral about GO and semicolon. Semicolon is statement terminator and GO is a batch terminator.
http://www.sqlservercentral.com/articles/SQL+Puzzles/thegocommandandthesemicolonterminator/2200/
GO --> Signals the end of a batch of Transact-SQL statements to the SQL Server utilities. This could be multiple lines with semi-colons on the end depending on the structure of the t-sql.
EDIT: Some times at work we create proc scripts that have permissions appended at the end, if you run the create proc without a GO at the end the permissions error because you are trying to grant access to a proc that hasn't been created. GO forces the creation of the proc before you apply the appropriate permissions.
精彩评论