SQL: Create SQL Server Trigger

9/7/2015 8:55:01 PM

Create a simply sql trigger for insert.

CREATE TRIGGER [dbo].[tr_MyTable__Insert] ON [dbo].[MyTable] 
FOR INSERT
AS
SET NOCOUNT ON
	
--update data in the rows just inserted

UPDATE		MyTable

SET			MyTable.DateCreated = GETDATE()

FROM		INSERTED

WHERE		INSERTED.Id = MyTable.Id			


GO