";" 和有什么不一样?和“去"在 T-SQL 中? [英] What is the difference between ";" and "GO" in T-SQL?

查看:29
本文介绍了";" 和有什么不一样?和“去"在 T-SQL 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ADO.NET 以及 sqlcmd 实用程序将 SQL 脚本发送到 SQL Server 2008.使用 ;GO 来分隔块的区别是什么?SQL?

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 chunks of SQL?

推荐答案

GO 实际上不是 T-SQL 命令.GO 命令是由 Microsoft 工具引入的,用于分隔批处理语句,例如存储过程的结尾.GO 受 Microsoft SQL 堆栈工具支持,但并未正式成为其他工具的一部分.

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.

您不能将 GO 放入 SQL 字符串并将其作为 ADO.NET 命令对象的一部分发送,因为 SQL 本身不理解该术语.演示这一点的另一种方法是使用探查器:在 Query Analyzer/Management Studio 中设置一些使用 GO 的语句,然后在执行时运行探查器.您将看到它们作为单独的命令发送到服务器.

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

这篇关于";" 和有什么不一样?和“去"在 T-SQL 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆