I already created the error in sys.message
. The problem is when I add it to my stored procedure, it doesn't pass me the message back. The stored procedure checks to see if an id exists in a certain areacode if the id does not exists the raiserror should be fired.
AS
BEGIN
DECLARE @Result as int
IF EXISTS(SELECT ID, areacode
FROM Table1
WHERE ID = @ID
AND areacode = @areacode)
RAISERROR (50030, 1, 1)
BEGIN
INSERT INTO Table2 ( //columns go here )
VALUES ( //values for columns )
END