I use ADO.NET as well as the sqlcmd utility to send SQL scripts to SQL Server 2008. What is the difference between using ;
and GO
to separate chunk
GO
is not actually a T-SQL command. The GO
command was introduced by Microsoft tools as a way to separate batch statements such as the end of a stored procedure. GO
is supported by the Microsoft SQL stack tools but is not formally part of other tools.
You cannot put a GO
into a string of SQL and send it as part of a ADO.NET command object as SQL itself does not understand the term. Another way to demonstrate this is with the profiler: set up some statements that use GO
in Query Analyzer/Management Studio and then run the profiler when you execute. You will see they are issued as separate commands to the server.
The semi-colon is used to signify the end of a statement itself, not necessarily a whole batch.
http://msdn.microsoft.com/en-us/library/ms188037.aspx