How to interpret this SQL Server error message

前端 未结 2 2023
清酒与你
清酒与你 2021-01-04 18:59

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         


        
相关标签:
2条回答
  • 2021-01-04 19:36

    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

    • BEGIN = line 0
    • next line (the actual start of the procedure = 1
    • etc

    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

    0 讨论(0)
  • 2021-01-04 19:43

    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
    
    0 讨论(0)
提交回复
热议问题