July 11, 2006 at 7:38 am
I have a SP which loads a text file into sql server tables. This SP is used in the application where the end user has to browse for the file and load it into tables. Now I want to raise some errors on the given conditions in my SP
How can I send the error message to the user who loads the file when he is trying to load it
July 11, 2006 at 8:45 am
From BOL v9:
RAISERROR ( { msg_id | { msg_str | @local_variable} }{ ,severity ,state } [ ,argument [ ,...n ] ] ) [ WITH option [ ,...n ] ]
msg_id
Is a user-defined error message number stored in the sys.messages catalog view using sp_addmessage. Error numbers for user-defined error messages should be greater than 50000. When msg_id is not specified, RAISERROR raises an error message with an error number of 50000.
msg_str
severity
state
Is an arbitrary integer from 1 through 127. A negative value for state defaults to 1. The value 0 or values larger than 127 generate an error.
Are the parameters used in the substitution for variables defined in msg_str or the message corresponding to msg_id. There can be 0 or more substitution parameters, but the total number of substitution parameters cannot exceed 20. Each substitution parameter can be a local variable or any of these data types: tinyint, smallint, int, char, varchar, nchar, nvarchar, binary, or varbinary. No other data types are supported.
Is a custom option for the error and can be one of these values:
LOG
Logs the error in the error log and the application log for the instance of the Microsoft SQL Server Database Engine. Errors logged in the error log are currently limited to a maximum of 440 bytes. Only a member of the sysadmin fixed server role or a user with ALTER TRACE permissions can specify WITH LOG.
NOWAIT
Sends messages immediately to the client.
SETERROR
Sets the @@ERROR and ERROR_NUMBER values to msg_id or 50000, regardless of the severity level.
Tim Wilkinson
"If it doesn't work in practice, you're using the wrong theory"
- Immanuel Kant
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply