Guest User

Untitled

a guest
Jan 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. CREATE TRIGGER dbo.TrgUpnInsert
  2. ON [CNLH Security Authentication].dbo.DateTimestamp
  3. AFTER INSERT,
  4. INSERT INTO [CNLH Security Authentication].dbo.EntranceInformation (DateTimestamp) Values (CURRENT_TIMESTAMP);
  5.  
  6. CREATE TRIGGER ModDate
  7. ON TableX
  8. AFTER INSERT
  9. AS
  10. BEGIN
  11. UPDATE X
  12. SET ModifiedDate = CURRENT_TIMESTAMP
  13. FROM TableX X
  14. JOIN inserted i ON X.key = i.key -- change to whatever key identifies
  15. -- the tuples
  16. END
  17.  
  18. ALTER TABLE myTable
  19. ADD CONSTRAINT CONSTRAINT_NAME
  20. DEFAULT CURRENT_TIMESTAMP FOR myColumn
  21.  
  22. IF OBJECT_ID('tempdb..#temp') IS NOT NULL
  23. DROP TABLE #temp
  24.  
  25. CREATE TABLE #temp (
  26. col1 VARCHAR(10)
  27. ,col2 DATETIME
  28. )
  29.  
  30. ALTER TABLE #temp ADD CONSTRAINT ConstraintForTemp DEFAULT CURRENT_TIMESTAMP
  31. FOR col2
  32.  
  33. INSERT INTO #temp (col1)
  34. VALUES ('abc')
  35.  
  36. SELECT *
  37. FROM #temp
Add Comment
Please, Sign In to add comment