‘%1!’ must be the first statement in a query batch.

Error Message:
Msg 111, Level 15, State 1, Line 7
‘%1!’ must be the first statement in a query batch.

Severity level:
15.

Description:
This error message appears, when you try to execute statements in a batch that need to be separated in different batches or that need to executed in a different order in the same batch.

Consequences:
The SQL statement cannot be parsed and further execution is stopped.

Resolution:
Error of the Severity Level 15 are generated by the user and can be fixed by the SQL Server user. The conflicting statements must either be separated by a batch separator (default GO), or, if possible from the point of view of your program logic executed in a different order. However, in most case restructuring of the order of statements will not be possible so that you have to resort to the separation in different batches.

Versions:
All versions of SQL Server.

Example(s):
USE tempDB

CREATE TABLE t
(
 c1 INT NOT NULL
)
CREATE FUNCTION dbo.udf(@now DATETIME)
RETURNS DATETIME
AS
BEGIN RETURN @now
END

DROP TABLE t
DROP FUNCTION dbo.udf

Remarks:
In the above example, the CREATE FUNCTION statement needs to be executed as the first statement of a new batch.




Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |