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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rosenberg
  • 2,424
  • 5
  • 33
  • 56
  • 1
    read this question http://stackoverflow.com/questions/5985486/how-to-run-a-database-script-file-from-delphil/5985810#5985810 – RRUZ May 13 '11 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 . – Lieven Keersmaekers May 13 '11 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. – Rosenberg May 13 '11 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. – Disillusioned May 14 '11 at 10:18
  • Alternatively, would replacing `GO` with `;` solve the problem? – Disillusioned May 14 '11 at 10:18

3 Answers3

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)

Oded
  • 489,969
  • 99
  • 883
  • 1,009
1

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

SQLMenace
  • 132,095
  • 25
  • 206
  • 225
1

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

SQLMenace
  • 132,095
  • 25
  • 206
  • 225
Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235