SHARE
TWEET

Untitled

a guest Feb 17th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SET ANSI_NULLS ON
  2. GO
  3. SET QUOTED_IDENTIFIER ON
  4. GO
  5. -- =============================================
  6. -- Author:      <Author,,Name>
  7. -- Create date: <Create Date,,>
  8. -- Description: <Description,,>
  9. -- =============================================
  10. CREATE TRIGGER DELETE_Loc
  11.    ON  dbo.Location
  12.    FOR DELETE
  13. AS
  14. IF EXISTS (SELECT COUNT(*) FROM deleted, Company
  15. WHERE Company_Id = deleted_Id )
  16. BEGIN
  17.     -- SET NOCOUNT ON added to prevent extra result sets from
  18.     -- interfering with SELECT statements.
  19.     --SET NOCOUNT ON;
  20.     -- Insert statements for trigger here
  21.     PRINT 'You cannot delete Location because Company exists'
  22.     ROLLBACK TRANSACTION
  23. END
  24. GO
RAW Paste Data
Top