“GO”附近语法错误- TADOQuery [duplicate]

时间:2022-06-18 22:48:23

Possible Duplicate:
How to run a database script file from Delphi?

可能重复:如何从Delphi运行数据库脚本文件?

I have a really long sql script to run with a query, it updates fields, create tables, create procedures, etc. So, there's a lot of the word 'GO' around, otherwise it won't function properly.

我有一个很长的sql脚本来运行查询,它更新字段、创建表、创建过程等等。所以,有很多单词“GO”,否则它就不能正常工作。

On the MSSQL Query the script works perfectly whereas on the ADO Query I get the following:

在MSSQL查询中,脚本运行良好,而在ADO查询中,我得到以下结果:

Incorrect syntax near 'GO'

“GO”附近的错误语法

EDIT: Ok, I think we got it pretty well established that ADO Query will not read the word GO. However, without the word GO my code will not work, procedures must be created in the first line and I have a couple of those thrown around the file. Which is an issue.

编辑:好的,我认为我们已经很好地确定了ADO查询不会读取单词GO。但是,如果没有GO这个词,我的代码将无法工作,必须在第一行中创建过程,并且我在文件中抛出了一些。这是一个问题。

The only workaround then would be to create separate queries?

那么,唯一的解决方法就是创建单独的查询?

3 个解决方案

#1


3  

Yes. Remove the GO - it is not valid SQL.

是的。删除GO -它不是有效的SQL。

It is syntax specific to Microsoft SQL utilities - see MSDN.

它是特定于Microsoft SQL实用程序的语法——请参阅MSDN。

Signals the end of a batch of Transact-SQL statements to the SQL Server utilities.

向SQL服务器实用程序发送一批Transact-SQL语句的结束信号。

(emphasis mine)

(强调我的)

#2


1  

Go is a batch terminator, it is not SQL, it is understood by SSMS. Just remove the GO when running from ADO

Go是一个批处理结束符,它不是SQL,它被SSMS理解。在运行ADO时,只需删除GO

#3


1  

GO is not a SQL command. It is a batch terminator recognized by SSMS

GO不是SQL命令。它是SSMS识别的批处理终止符

#1


3  

Yes. Remove the GO - it is not valid SQL.

是的。删除GO -它不是有效的SQL。

It is syntax specific to Microsoft SQL utilities - see MSDN.

它是特定于Microsoft SQL实用程序的语法——请参阅MSDN。

Signals the end of a batch of Transact-SQL statements to the SQL Server utilities.

向SQL服务器实用程序发送一批Transact-SQL语句的结束信号。

(emphasis mine)

(强调我的)

#2


1  

Go is a batch terminator, it is not SQL, it is understood by SSMS. Just remove the GO when running from ADO

Go是一个批处理结束符,它不是SQL,它被SSMS理解。在运行ADO时,只需删除GO

#3


1  

GO is not a SQL command. It is a batch terminator recognized by SSMS

GO不是SQL命令。它是SSMS识别的批处理终止符