January 22, 2006 at 10:32 am
Hey, I have one table. This table I check of update. And now I want to insert into 2 other table the changes.
If the update are in the rows which have in the "art" column an 'D' have this row insert into table 1
If the update are in the rows which have in the "art" column an 'K' it have to insert into table 2.
How can I make this ?
Thanks for help !
Markus
January 22, 2006 at 11:13 am
This is quite simple using the INSERTED (containing updated values) AND DELETED table (containing deleted values)
CREATE TRIGGER TR_UPDATE_ART_INSERT_TO on ARTTABLE
FOR UPDATE /*only updates*/
AS
SET NOCOUNT ON /*reduce unnecessary roundtrip to client*/
INSERT INTO TABLE1
(field1,field2,...)
SELECT field1,field2...
from DELETED /*old values; INSERTED= new values*/
WHERE DELETED.art='D'
INSERT INTO TABLE2
(field1,field2,...)
SELECT field1,field2...
from DELETED
WHERE art='K'
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply