October 14, 2014 at 1:40 pm
how I can capture an error message returned by a stored procedure, and puts it into a variable.
thank you
October 14, 2014 at 2:11 pm
The best way to do this is by using TRY...CATCH... blocks.
Read more about them in here: http://msdn.microsoft.com/en-us/library/ms175976(v=sql.100).aspx
Or search on the internet for more information and come back with any questions that you have.
February 16, 2015 at 8:11 am
BEGIN TRY
-- Generate a divide-by-zero error.
SELECT 1/0;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
GO
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply