What is the difference between “;” and “GO” in T-SQL?

后端 未结 7 909
抹茶落季
抹茶落季 2020-12-28 12:40

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

7条回答
  •  感动是毒
    2020-12-28 13:35

    'GO' is typically used to indicate the end of a batch of SQL statements which means that you could have a begin transaction and end transaction wrapped up into a single collection of statements that could fail or succeed together.

    ';' is generally used to separate multiple SQL statements from one another. This is noticable in SQL scripts that need to return multiple recordsets, such as `select * from table1; select * from table2;' which would result in two separate recordsets on the client's side.

提交回复
热议问题