Hi,
I have a stored proc StoredProc1 =
{
INSERT INTO Table1
SELECT *
FROM View1
Return @@ERROR
}
StoredProc1 is used in another sp StoredProcMain =
{
(some code before)...
EXEC @iResult = StoredProc1
If @iResult <> 0
BEGIN
ROLLBACK TRANSACTION
Return @iResult
END
.... (continue)
}
So I want to rollback if StoredProc1 is not successful.
Then I ran into a problem. I added a column to Table1 but forgot to
update View1 to add the equivalent column. When I executed
StoredProc1, I got the "Insert Error: Column name or number of
supplied values does not match table definition." But the error is
NOT trapped. It seems the instruction "Return @@ERROR" returns 0 and
StoredProcMain goes on as if there wasn't an error.
How can I trap this error?
Thanks
Walter