Raising error to jump to CATCH block

by Joe Hunter 6. July 2010 11:22

Unfortunately up to this point I was using select 1/0 to force an error and jump to The CATCH block.

 Thankfully I have started using this method instead 

IF @ERR IS NOT NULL RAISERROR (@ERR, 16,1 )

 Where 16 represents the SEVERITY. Using a value between 11 to 19 causes execution to jump to the CATCH block.

1 represents the STATE and is an arbitrary integer.

 Reference:

http://msdn.microsoft.com/en-us/library/ms178592%28SQL.90%29.aspx

 

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen