How can I find the error code thrown in SQL Server? -
i have code:
if (@@rowcount != 1) throw 50004,'mark_test - problem setting test status marked',1
i know can error message this:
set @errormessage = error_message()
but how can number 50004 ?
use error_number
function
returns error number of error caused catch block of try…catch construct run.
demo
begin try select 1 union select 1 if ( @@rowcount != 1 ) throw 50004, 'mark_test - problem setting test status marked', 1 end try begin catch select error_number=error_number(), error_message=error_message() end catch
result
error_number error_message 50004 mark_test - problem setting test status marked
Comments
Post a Comment