Reputation: 1154
Why this returns error:
DROP VIEW vTest; GO
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'GO'.
And this works fine:
DROP VIEW vTest;
GO
And how to adjust first statement so that it runs fine on the same line?
Upvotes: 0
Views: 81
Reputation: 3970
If you're passing SQL to SQL Server via an API, you do not need the "GO". The "GO" is a feature of OSQL.exe, ISQL.exe, SQLCMD.exe, and SQL Server Management Studio. It's not a feature of SQL Server or T-SQL. So if you're coding in C# or javascript or Ruby or Perl or whatever, and you're just trying to execute some SQL via an API... just pass the SQL, no "GO" commands, and it'll work for you.
The "GO" is just a "batch separator", separating batches of SQL to be sent to SQL Server. It's utterly unnecessary here, when you have only one batch.
Upvotes: 1