Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

symbols in sysmessges?

Status
Not open for further replies.

tc3596

Technical User
Mar 16, 2001
283
I need to understand the meanings of the symbols in the description field of sysmessges in the master database. Books online says they are datatypes (i.e. %ls or %.*ls = Character string) How does it know to pull in the user name when the message displays "login failed for user '%ls'? I want to build more detailed error messages, this is why I am asking.
 

SQL Server fills in the variables from the parameter values passed in the RAISERROR statement. RAISERROR accepts up to 20 parameters which are substituted for the variables in the message string based on position. The first parameter in the RAISERROR call is substituted for the first variable in the message string, the 2nd parameter for the 2nd variable and so forth.

Example:

Suppose the message text for error #50005 is "The level for job_id: %d should be between %d and %d." You might issue the following RAISERROR call.

RAISERROR (50005, 16, 1, 101, 2, 7)

This would result in the following message display.

The level for job_id: 101 should be between 2 and 7.

I suggest reading about RAISERROR in SQL BOL for more information, syntax and examples.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top