i need to archive any changes made to one of my tables...i thought i might be able to do it with a trigger, but i'm beginning to think otherwise....here is the code for my trigger:
---------------------------------
CREATE TRIGGER tblRunCardProcessData_RevisionTrigger
ON dbo.tblRunCardProcessData
FOR UPDATE
AS
DECLARE @rcid int
DECLARE @wcpid int
DECLARE @wcpval varchar(50)
DECLARE @wcptol varchar(50)
BEGIN
SELECT
@rcid = RunCard_ID,
@wcpid = WCProcess_ID,
@wcpval = WCProcess_val,
@wcptol = WCProcess_tol
FROM
tblRunCardProcessData
WHERE
RunCardProcessData_ID = Inserted.RunCardProcessData_ID
END
BEGIN
INSERT INTO
tblRevisions
( RunCard_ID, WCProcess_ID, old_WCProcess_val, old_WCProcess_tol )
VALUES
( @rcid, @wcpid, @wcpval, @wcptol )
END
---------------------------------
this won't even compile...if i delete my where clause, it will compile, but i'm not sure if it is working, because i can't get a reference to the inserted row then. any ideas on what the syntax error could be there (it's sql 7)
another question, will this fire before the insert, or should i just forget about using a trigger and put the logic in my insert stored procedure?
thanks all.
mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
---------------------------------
CREATE TRIGGER tblRunCardProcessData_RevisionTrigger
ON dbo.tblRunCardProcessData
FOR UPDATE
AS
DECLARE @rcid int
DECLARE @wcpid int
DECLARE @wcpval varchar(50)
DECLARE @wcptol varchar(50)
BEGIN
SELECT
@rcid = RunCard_ID,
@wcpid = WCProcess_ID,
@wcpval = WCProcess_val,
@wcptol = WCProcess_tol
FROM
tblRunCardProcessData
WHERE
RunCardProcessData_ID = Inserted.RunCardProcessData_ID
END
BEGIN
INSERT INTO
tblRevisions
( RunCard_ID, WCProcess_ID, old_WCProcess_val, old_WCProcess_tol )
VALUES
( @rcid, @wcpid, @wcpval, @wcptol )
END
---------------------------------
this won't even compile...if i delete my where clause, it will compile, but i'm not sure if it is working, because i can't get a reference to the inserted row then. any ideas on what the syntax error could be there (it's sql 7)
another question, will this fire before the insert, or should i just forget about using a trigger and put the logic in my insert stored procedure?
thanks all.
mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu