Link to home
Start Free TrialLog in
Avatar of Jyozeal
JyozealFlag for United States of America

asked on

Error handling in SQL Server

Hi All,

Please consider below code.
Msg 2714, Level 16, State 6, Procedure P_CreateSampleTable, Line 93
There is already an object named 'sampletable' in the database.

Open in new window


for retrieivng the errornumber and state we can use ERROR_NUMBER(), ERROR_STATE() etc.
What should be used to retrieve the object where error is reported from in this case "Procedure P_CreateSampleTable".

Also line no doesn't seem to exactly represent the source of error. Regret if this is too trivial. Any inputs are appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jyozeal

ASKER

Thanks. When i use ERROR_LINE() the line no given by SQL Server is differing from the line no where actually the error is. Any idea why this is happening?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial