I want to display my own error message when something goes wrong in executing the below procedure rather than displaying the sqlserver error message.
Suppose in the below procedure during updation if we set value of attribute, 'userid' which already exists in the database, an error willbe raised by sqlserver as 'userid' is primary key and duplicates are not allowed. Eventhough I incorporated a sql, 'select' statement whch intimates about error and rollback the transaction , sqlserver error message is displayed rather than the 'select' statement result which intimates me about the error encounterd. Can anyone of you suggest how to override the sqlserver error message and displaying my own error message and how could we get the sqlserver raised error description.
CREATE procedure admin_modify
= count(*) from admin where userid = @olduserid
select 'failure' as result,'Admin ' + @olduserid
+ 'Not Found' as description
set userid = @newuserid
,password = @newpassword
where userid = @olduserid
and password = @error<
select 'failure' as result,'Error Encountered While Modifying Admin ' + @olduserid
+ 'Details' as description
select 'success' as result,'' as description