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 2005 Forums
 Transact-SQL (2005)
 Error 209: Ambiguous column name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bholmstrom
Yak Posting Veteran

USA
75 Posts

Posted - 03/15/2013 :  09:49:01  Show Profile  Reply with Quote
This trigger is failing, can anyone see whats wrong?

CREATE TRIGGER [update_status_date] ON [dbo].[NCOS_Data]
FOR UPDATE
AS
Update p
SET NC_Status_Date = getdate(),
NC_Status_Previous = NC_Status
from inserted i
join ncos_data p on p.NC_UniqueID = i.NC_UniqueID

Error is: Error 209 Ambiguous column name 'NC_Status'

Thanks

Bryan Holmstrom

webfred
Flowing Fount of Yak Knowledge

Germany
8766 Posts

Posted - 03/15/2013 :  09:51:11  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by bholmstrom

This trigger is failing, can anyone see whats wrong?

CREATE TRIGGER [update_status_date] ON [dbo].[NCOS_Data]
FOR UPDATE
AS
Update p
SET NC_Status_Date = getdate(),
NC_Status_Previous = i.NC_Status
from inserted i
join ncos_data p on p.NC_UniqueID = i.NC_UniqueID

Error is: Error 209 Ambiguous column name 'NC_Status'

Thanks

Bryan Holmstrom




Too old to Rock'n'Roll too young to die.
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8766 Posts

Posted - 03/15/2013 :  09:52:31  Show Profile  Visit webfred's Homepage  Reply with Quote
but if you really want the previous status then you should use deleted instead of inserted


Too old to Rock'n'Roll too young to die.
Go to Top of Page

bholmstrom
Yak Posting Veteran

USA
75 Posts

Posted - 03/15/2013 :  10:15:43  Show Profile  Reply with Quote
WebFred

Should I do 2 seperate triggers or 1?

The field NC_Status_Date gets the current datetime when the field is changed, and the NC_Status_Previous should get the previous value of NC_Status if it changed.

Not sure how do this....

Thanks

Bryan Holmstrom
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8766 Posts

Posted - 03/15/2013 :  13:10:45  Show Profile  Visit webfred's Homepage  Reply with Quote
change inserted with deleted and everything is fine


Too old to Rock'n'Roll too young to die.
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