Page 1 of 1

getting complete error information?

Posted: Thu 28 May 2009 10:14
by Ludek
if i execute following query

Code: Select all

begin try
  raiserror('test', 11, 1)
end try  
begin catch
  raiserror('test2', 20, 1) with log
end catch
i get in sql management studio following messages
Msg 2745, Level 16, State 2, Line 5
Process ID 71 has raised user error 50000, severity 20. SQL Server is terminating this process.
Msg 50000, Level 20, State 1, Line 5
test3
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
in sdac, i get just
Der Prozess mit der ID 57 hat den Benutzerfehler 50000, Schweregrad 20, ausgelöst. Dieser Prozess wird von SQL Server beendet.
test3
it means, only 2 of 3 messages that sql management studio gets... how can i get the third?
and, how could i get message numbers, severity levels and lines?

Posted: Thu 28 May 2009 11:14
by Dimon
The third error is generated by SQL Management Studio and therefore you can't get it in application.

Posted: Thu 28 May 2009 14:12
by Ludek
hmmm, it's possible, i don't know...

and exception other info? exception class (=severity), message, procedure and line? i don't know, how could i access these infos with sdac (in vs 2008 are they stored as properties of the exception class SqlException)

Posted: Fri 29 May 2009 07:11
by Dimon
To get access to the information about all errors generated by SQL server you should catch EMSError exceptions. The EMSError.Errors property contains an array of errors returned by the server and all information about them.
You can find more detailed information about this class in the SDAC help.