3

Possible Duplicate:
How to run a database script file from 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.

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

Incorrect syntax near '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.

The only workaround then would be to create separate queries?

5
  • 1
    read this question stackoverflow.com/questions/5985486/… Commented May 13, 2011 at 20:01
  • Voting to close. The answer provided by RRUZ in the related question should be enough for OP to get going. Oh, and btw, the GO statement is not a valid SQL command <vbg>. Commented May 13, 2011 at 20:18
  • I agree, I want to pick one but they all gave the same answer, which would make it kind of unfair. Please, close this thread. Commented May 13, 2011 at 21:07
  • Based on your edit, you could post a question about how to deal with a script containing stored procedures/triggers etc. and the required GO statements. However it will be similar to RRUZ's answer to the other question; except that you'll want to execute each section of your script between GO statements as separate queries instead one large query with GO simply removed. Commented May 14, 2011 at 10:18
  • Alternatively, would replacing GO with ; solve the problem? Commented May 14, 2011 at 10:18

3 Answers 3

3

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

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

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

(emphasis mine)

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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

1 Comment

Oops, by mistake edited your answer..sorry about that, I reverted it back

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.