Guest User

Untitled

a guest
Jan 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. CREATE TABLE [dbo].[table] (
  2. tableID [int] IDENTITY(1,1) NOT NULL
  3. , DatumCreate [datetime] DEFAULT GetDate() NOT NULL,
  4. , other values ....
  5. , CONSTRAINT pk_FactuurID PRIMARY KEY (FactuurID)
  6. )
  7. GO
  8.  
  9. CREATE TRIGGER my_trigger
  10. ON my_table
  11. AFTER INSERT, UPDATE, DELETE
  12. AS
  13. BEGIN
  14. if exists(select * from inserted)
  15. -- we're covering just insert cases here..
  16. begin
  17. insert into my_table(col1, col2, col3, ..., col_timestamp)
  18. select inserted.col1, inserted.col2...., CURRENT_TIMESTAMP from inserted
  19. end
  20. END
  21.  
  22. GO
Add Comment
Please, Sign In to add comment