Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Upadate Triggers

Author  Topic 

vikramsdev
Starting Member

1 Post

Posted - 2005-05-03 : 05:10:19
Hi

I need help for creat update trigger for update of one colume for perticuler record table reflect or update other teble col and perticuler row.


Plz help me

Vikram

vijayakumar_svk
Yak Posting Veteran

50 Posts

Posted - 2005-05-03 : 05:38:41
Hi,

Assume that you have table called TableX and TableY. For Eg you are having id,Amount column in both the table. When ever TableX gets updated we need to upadte TableY as well. Use the following script to get the work done.

CREATE TRIGGER [dbo].TableX_UTrig ON dbo.TableX FOR Update AS
Declare @id int
Declare @Amount numeric(18,4)
-- You can get the id and Amount value from updated row
Select @id=id,@Amount=Amount from inserted

Update TableY set Amount=Amount+@Amount where id=@id
-------------------------------------------------------------------
I realy dont know what your table structure and purpose. Take this as example and make use of it for your scenario.
---------------------------



Work smarter not harder take control of your life be a super achiever
Go to Top of Page
   

- Advertisement -