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 2008 Forums
 SQL Server Administration (2008)
 What am I doing wrong :(

Author  Topic 

drawlings
Starting Member

14 Posts

Posted - 2013-03-26 : 08:09:24
I have a update trigger, but I keep getting a error message when I try to excute the statement

Trigger

BEGIN

SET NOCOUNT ON;

update A_Table
set EndDtm = inserted.Enddtm
from timesheetitem
where a_table.timesheetid = inserted.TimeSheetItemID


END

Error Message

The multi-part identifier "inserted.TimeSheetItemID" could not be bound.

I have tried different variations, but they all give me the same error

SET NOCOUNT ON;

update A_Table
set a_table.EndDtm = inserted.Enddtm
from timesheetitem
join inserted on a_table.timesheetid = inserted.timesheetitemid


END




My Free .NET Controls at www.qiosdevsuite.com Includes 30 Controls, Ribbon Toolbar, Ribbon Form etc...

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-26 : 08:22:13
That logic somehow does not seem to be correct. If the trigger is on the table timesheetitem, the trigger code should be like this:
update A
set EndDtm = i.Enddtm
from
A_Table a
inner join INSERTED i on i.timesheetid = a.timesheetid;
Go to Top of Page

drawlings
Starting Member

14 Posts

Posted - 2013-03-26 : 08:40:44
Thanks James, I did realised what I was doing wrong.

My Free .NET Controls at www.qiosdevsuite.com Includes 30 Controls, Ribbon Toolbar, Ribbon Form etc...
Go to Top of Page
   

- Advertisement -