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.
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.