Posted By

RealRover on 08/05/10


Tagged

catch try raiserror


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


TRY - RAISERROR - CATCH


 / Published in: SQL
 

  1. BEGIN TRY
  2.  
  3. /* Code here */
  4.  
  5. DECLARE @UserGroupId INT
  6. INSERT INTO UserGroup (RoleId, ScopeGroupId)
  7. VALUES (5555, 7777)
  8. SET @UserGroupId = SCOPE_IDENTITY()
  9. IF @UserGroupId IS NULL
  10. RAISERROR('User group creation failed', 16, 1)
  11.  
  12. END TRY
  13. BEGIN CATCH
  14. SELECT ERROR_MESSAGE() AS Error
  15. END CATCH

Report this snippet  

You need to login to post a comment.