INSERT INTO [Case] (FileYear, FileNbr)
VALUES (@FileYear, @FileNbr)
IF @@ERROR = 0
BEGIN
SET @ReturnCode = 0
END
ELSE
BEGIN
SET @ReturnCode = -1
END
return
-------
I have written this in a stored procedure. If the FileYear and FileNbr are duplicates and already exist in the database I want to set @ReturnCode = -1. If they do not exist I want to set it to 0. I run this stored procedure from an ASP page. When the procedure finds it to be duplicates the system automatically aborts the procedure and sends a duplicate record message to the screen and the "IF @Error = 0" statement never gets executed. Why can't I get the rest of the procedure to execute and how can I over come this?