Guest User

Untitled

a guest
Dec 17th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. CREATE TRIGGER ModDate
  2. ON X
  3. AFTER INSERT, UPDATE
  4. AS
  5. BEGIN
  6.  
  7. INSERT INTO X (ModifiedDate)
  8. VALUES (GETDATE())
  9.  
  10. END
  11.  
  12. CREATE TRIGGER ModDate
  13. ON TableX
  14. AFTER INSERT, UPDATE
  15. AS
  16. BEGIN
  17. UPDATE X
  18. SET ModifiedDate = GETDATE()
  19. FROM TableX X
  20. JOIN inserted i ON X.key = i.key -- change to whatever key identifies
  21. -- the tuples
  22. END
  23.  
  24. CREATE TRIGGER ModDate
  25. ON TableX
  26. AFTER INSERT
  27. AS
  28. BEGIN
  29. UPDATE tableX SET ModifiedDate = GETDATE() where modifieddate is null
  30. END
  31.  
  32. create trigger [dbo].[ModDate] on [dbo].[x] after insert,update
  33. as
  34. begin
  35.  
  36. UPDATE dbo.x
  37. SET x.ModifiedDate = GETDATE()
  38. FROM x X
  39. JOIN inserted I ON X.key = I.key
  40.  
  41. end
Add Comment
Please, Sign In to add comment