tia
Greetings,
DoraThere is a virtual table called INSERTED. You can join to other tables, select the columns into variables, etc.|||Here's a sample of an insert trigger that does something similar to what you are asking for...
CREATE TRIGGER TrgIn_Areas
ON dbo.Areas FOR INSERT AS
DECLARE @.dDate DATETIME
DECLARE @.strName VARCHAR(30)
SELECT @.dDate = GETDATE()
SELECT @.strName = (SELECT nt_username
FROM master..sysprocesses
WHERE spid = (SELECT @.@.SPID))
UPDATEAreas
SET CreatedBy = @.strName,
CreatedDate = @.dDate
FROM inserted
WHEREAreas.AreaID = inserted.AreaID
No comments:
Post a Comment