In this article we will discuss a new error message (The batch could not be analyzed because of compile errors) that appears in SQL SERVER 2012.
Let’s discuss it in detail:
Message Number: 11501
Severity : 16
Error Message: “The batch could not be analyzed because of compile errors”
Error Generation:
In my previous article, I discussed about sp_describe_undeclared_parameters, this error message is somehow related to sp_describe_undeclared_parameters (because of the batch processing). But it can also be generated wherever batch processing is involved.
Let me create an example to generate this error:
USE AdventureWorks2012 GO sp_describe_undeclared_parameters @tSQL= N'SELECT @BusinessID=[BusinessEntityID] from [HumanResources].[vEmployee] Where [FirstName]=@FName' ,@params =N'@FName nvarchar(50),, @BusinessID INT OUTPUT' --OUTPUT
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ‘,’.
Msg 11501, Level 16, State 2, Line 1
The batch could not be analyzed because of compile errors.
Resolution:
The reason behind this error is whenever you pass any incorrect input parameter to process any batch and if there is any error in the input parameter, it will generate this error with the combination of actual error. In the above example, I placed two commas instead of one in the parameter and then it generated two errors 1st one to notify actual error Incorrect syntax near ‘,’ also it notifies that The batch could not be analyzed because of compile errors. Whenever you are using any batch processing command, make sure that the input parameters are correct.
Please let me know if you have other samples to regenerate such error.
Leave a Reply