SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 What am I doing wrong :(
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

drawlings
Starting Member

United Kingdom
14 Posts

Posted - 03/26/2013 :  08:09:24  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3649 Posts

Posted - 03/26/2013 :  08:22:13  Show Profile  Reply with Quote
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

United Kingdom
14 Posts

Posted - 03/26/2013 :  08:40:44  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000