I am executing a stored proc from SSMS and I get this error message:
Msg 295, Level 16, State 3, Procedure spEdiCreateOrders, Line 80 [Batch Start Line 2]
Co
When looking at the code of a stored procedure using the Alter procedure, the error line is from the BEGIN command, as the error occurred in the procedure, not in the Alter procedure command
Batch line 2 means the second batch of statements - this means you have a GO
somewhere in the procedure, and this is in the second set of statements (http://sqlhints.com/tag/examples-of-sql-go-statement/), the first set appearing before the GO
About Line n
N
it is refer to the number of line of object considering any spaces with in it , or before its body.
Example 1
Assume the next is SQLQuery window after clicking New Query button in SSMS
1. Create proc spTest1
2. As
3. Begin
4. Select 1/0
5. End
after executing spTest1
, you will get the next message
Msg 8134, Level 16, State 1, Procedure spTest1, Line 4
Example 2
Assume the next is SQLQuery window after clicking New Query button in SSMS
1.
2.
3.
4.
5.
6. Create proc spTest2
7. As
8. Begin
9. Select 1/0
10. End
after executing spTest2
, you will get the next message
Msg 8134, Level 16, State 1, Procedure spTest2, Line 9
Conclusion how get the accurate number
For getting the accurate number use the system stored procedure sp_helptext
as next
Exec sp_helptext spName