View Single Post
Old November 12th, 2004, 11:20 AM
happygv happygv is offline
Friend of Wrox
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

Hi Arsi,

You were not using the INSERTED and DELETED tables as given in my suggested code. INSERTED and DELETED tables are the ones that can be used only within TRIGGERS, where INSERTED holds the the ROW with the NEW values that you pass for UPDATE statement, and DELETED holds the record with the OLD VALUES that were there in the orginal table before UPDATE was done.

Hope this explains better. I was under assumption that you would be having knowledge about these two table, that is the reason why I didnot explain on that.
ALTER  TRIGGER [Update_DB] ON [dbo].[ProjectInfo] 
If UPDATE(ProjectName)
    UPDATE ProjectStatus..ProjectInfo2
    SET ProjectName = i.ProjectName
    FROM DELETED d, ProjectStatus..ProjectInfo t, INSERTED i
    WHERE d.ProjectName = t.ProjectName
This should be how it should look like, if needed make some alterations to this code so as to work as expected.

Hope that helps.

- Vijay G
Strive for Perfection