SQL-SERVER trigger to update datetimefield automatically

علی ذوالفقار
1400/04/21 09:26:14 (674)
CREATE TRIGGER [TR_SET_UPDATE_DATETIME] 
ON [TBL_TEST]
FOR UPDATE
AS
BEGIN
	DECLARE @id int 
	SELECT  @id = id FROM inserted 	
	UPDATE  tbl_file_request SET up_datetime = GETDATE() WHERE id = @id 	
	-- OR
	-- UPDATE TBL_NAME SET UDATE = GETDATE() WHERE ID IN (SELECT ID FROM INSERTED)	
END
Back