Hi guys,
Do you have complete reference for sql error numbers?
I want to design customize error message, I want to know how to RAISERROR
with correct error number. thanksHi
select * from master.dbo.sysmessages
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Britney" <britneychen_2001@.yahoo.com> wrote in message
news:#abp4FQIFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi guys,
> Do you have complete reference for sql error numbers?
> I want to design customize error message, I want to know how to RAISERROR
> with correct error number. thanks
>
>|||Between this and BOL you should be able to figure it all out:
SELECT *
FROM master..sysmessages
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Britney" <britneychen_2001@.yahoo.com> wrote in message
news:%23abp4FQIFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Hi guys,
> Do you have complete reference for sql error numbers?
> I want to design customize error message, I want to know how to RAISERROR
> with correct error number. thanks
>
>|||I tried a test, In this case, table4 doesn't exist in database,
but how can I print out this error ? I want to set this error to a
variable,
maybe to store in in error log table later on.
CREATE PROCEDURE testme
AS
select * from table4
return @.@.error
declare @.errornumber int
exec @.errornumber = testme
print @.errornumber
result:
Server: Msg 208, Level 16, State 1, Procedure testme, Line 3
Invalid object name 'table4'.
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:%23XSu5KQIFHA.3332@.TK2MSFTNGP14.phx.gbl...
> Hi
> select * from master.dbo.sysmessages
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "Britney" <britneychen_2001@.yahoo.com> wrote in message
> news:#abp4FQIFHA.2476@.TK2MSFTNGP12.phx.gbl...
RAISERROR
>|||Britney,
Please read Erland Sommarskog's article on error handling so you can get a
handle on batch abortion and other niceties of SQL Server error handling...
http://www.sommarskog.se/error-handling-I.html
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Britney" <britneychen_2001@.yahoo.com> wrote in message
news:exLi5RQIFHA.2476@.TK2MSFTNGP12.phx.gbl...
> I tried a test, In this case, table4 doesn't exist in database,
> but how can I print out this error ? I want to set this error to a
> variable,
> maybe to store in in error log table later on.
>
> CREATE PROCEDURE testme
> AS
> select * from table4
> return @.@.error
> declare @.errornumber int
> exec @.errornumber = testme
> print @.errornumber
> --
> result:
> Server: Msg 208, Level 16, State 1, Procedure testme, Line 3
> Invalid object name 'table4'.
>
> "Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
> news:%23XSu5KQIFHA.3332@.TK2MSFTNGP14.phx.gbl...
> RAISERROR
>|||I don't think I can set severity 16 error number to a variable.
"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:OVFeyUQIFHA.2476@.TK2MSFTNGP12.phx.gbl...
> Britney,
> Please read Erland Sommarskog's article on error handling so you can get a
> handle on batch abortion and other niceties of SQL Server error
handling...
> http://www.sommarskog.se/error-handling-I.html
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
> "Britney" <britneychen_2001@.yahoo.com> wrote in message
> news:exLi5RQIFHA.2476@.TK2MSFTNGP12.phx.gbl...
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment