Thursday, April 3, 2008

Try-catch in SQL

Ever wanted Try-catch in SQL?
Here's your chance!
2005 only



BEGIN TRY
SELECT convert(smallint, '2003121')
END TRY
BEGIN CATCH
select 'errno: ' + ltrim(str(error_number()))
select 'errmsg: ' + error_message()
END CATCH

No comments: