Incorrect syntax near #39;GO#39;(“GO附近的语法不正确)
问题描述
如何通过 ADO.NET 在单个命令(单次执行)中执行以下 SQL?
How can I execute the following SQL inside a single command (single execution) through ADO.NET?
ALTER TABLE [MyTable]
ADD NewCol INT
GO
UPDATE [MyTable]
SET [NewCol] = 1
不支持批处理分隔符 GO,如果没有它,第二个语句将失败.
The batch separator GO is not supported, and without it the second statement fails.
除了使用多个 command 执行之外,还有其他解决方案吗?
Are there any solutions to this other than using multiple command executions?
推荐答案
GO 关键字不是 T-SQL,而是一个 SQL Server Management Studio 神器,它允许您分离脚本的执行文件分多批.即当您在 SSMS 中运行 T-SQL 脚本文件时,语句会分批运行,由 GO 关键字分隔.可以在此处找到更多详细信息:https://msdn.microsoft.com/en-我们/图书馆/ms188037.aspx
The GO keyword is not T-SQL, but a SQL Server Management Studio artifact that allows you to separate the execution of a script file in multiple batches.I.e. when you run a T-SQL script file in SSMS, the statements are run in batches separated by the GO keyword. More details can be found here: https://msdn.microsoft.com/en-us/library/ms188037.aspx
如果你读到这里,你会发现 sqlcmd 和 osql 也支持 GO.
If you read that, you'll see that sqlcmd and osql do also support GO.
SQL Server 不理解 GO 关键字.因此,如果您需要等价物,则需要自行分离并单独运行批次.
SQL Server doesn't understand the GO keyword. So if you need an equivalent, you need to separate and run the batches individually on your own.
这篇关于“GO"附近的语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“GO"附近的语法不正确
基础教程推荐
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在多列上分布任意行 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
