You can get the error messages also with:
SELECT
error,
severity,
description
FROM
sysmessages
For user-friendly error messages, you can use RAISERROR and create your own message each time. You can also add messages to sysmessages with sp_addmessage. If you do this, you should use an error number over 50000. The format for RAISERROR is:
1. For a custom message each time.
SELECT * FROM whatever
IF @@ERROR <> 0
BEGIN
RAISERROR('Problem with select statement',16,1)
END
2. If you have created a user-defined message in sysmessages, you can simply reference it.
SELECT * FROM whatever
IF @@ERROR <> 0
BEGIN
RAISERROR(60001,16,1)
END
To find out more, look in Books Online as Tara stated. You can get information by going to the index tab and look at "RAISERROR", "severity levels", and "errors-SQL Server".
MeanOldDBA
derrickleggett@hotmail.com
When life gives you a lemon, fire the DBA.