TRY - RAISERROR - CATCH


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.