Error!
Success!

Exceptions handling using try….Catch in MS SQL 2005

0
kicks

Exceptions handling using try….Catch in MS SQL 2005  (Unpublished)

Exceptions handling using try….Catch in MS SQL 2005 Microsoft Add new feature ‘Try…Catch’ in MS SQL 2005. You can exception handling in MS SQL 2005 using the Try Catch. If divide by zero exception then returns the error is ‘Divide by Zero error encountered. i.e Declare @i int,@j int Select @i=200,@j=0 Select @i/@j Print @@Error Run this query in Query analyzer. you will get the error message Divide by Zero error encountered. Syntex for Try….Catch BEGIN TRY END TRY BEGIN CATCH END CATCH DECLARE @i int , @j int SELECT @i =100, @j =0 BEGIN TRY SELECT @i/@j END TRY BEGIN CATCH SELECT ERROR_NUMBER() as ErrorNo, ERROR_MESSAGE() as ErrMessage END CATCH


Kicked By:
Drop Kicked By: