Thanks Bill.. With the changes suggested by you, the trigger worked fine. Thanks again.
 
----- Original Message -----
From: Bill Ho
To: JDJList
Sent: Wednesday, June 12, 2002 1:52 PM
Subject: [jdjlist] Re: Problem Using Sql server trigger

Hi Jissy,

If you use variables to store the selected values, those values will be kept overridded by the next one.  That's why only the values of the last row got inserted into test5.  Instead, you should insert into test5 directly.  Since I don't have SQL server with me, so I am not sure about the syntax.  Anyway, please try the following:

create trigger test4_tgr on test4 for update as
insert into test5 (testid, testname)
select testid, testname from INSERTED;

Hope this helps!

Bill

Jissy wrote:

Hi All Can anyone help me solve the problem I'm facing using Sql server triggers. I have a trigger as follows: create trigger test4_tgr on test4 for update as declare @id int declare @name varchar (60) select @id=testid, @name=testname FROM INSERTED INSERT INTO test5 (testid, testname) values (@id, @name); The problem is that if execute an update sql, and the sql execution results in more than one row getting updated in test4, only one row gets inserted into table test5, corresponding to the last row that was updated in table4. So, i'm unable to track all updations done on table test4. Does anyone know of any list where I can post this question? ThanksJissy  To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to