I have a trigger
which deals with some data for logging purposes like so:
CREATE TRIGGER trgDataUpdated
ON tblData FOR UPDATE
AS
BEGIN
INSERT INTO tblLog ( ParentID, OldValue, NewValue, UserID )
SELECT deleted.ParentID, deleted.Value, inserted.Value,
@intUserID -- how can I pass this in?
FROM inserted INNER JOIN deleted ON inserted.ID = deleted.ID
END
How can I pass in the variable @intUserID
into the above trigger, as in the following code:
DECLARE @intUserID int
SET @intUserID = 10
UPDATE tblData
SET Value = @x
PS: I know I can't literally pass in @intUserID
to the trigger, it was just used for illustration purposes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…