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.
Author |
Topic |
bholmstrom
Yak Posting Veteran
76 Posts |
Posted - 2013-03-15 : 09:49:01
|
This trigger is failing, can anyone see whats wrong?CREATE TRIGGER [update_status_date] ON [dbo].[NCOS_Data] FOR UPDATEASUpdate p SET NC_Status_Date = getdate(), NC_Status_Previous = NC_Statusfrom inserted ijoin ncos_data p on p.NC_UniqueID = i.NC_UniqueIDError is: Error 209 Ambiguous column name 'NC_Status'ThanksBryan Holmstrom |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-03-15 : 09:51:11
|
quote: Originally posted by bholmstrom This trigger is failing, can anyone see whats wrong?CREATE TRIGGER [update_status_date] ON [dbo].[NCOS_Data] FOR UPDATEASUpdate p SET NC_Status_Date = getdate(), NC_Status_Previous = i.NC_Statusfrom inserted ijoin ncos_data p on p.NC_UniqueID = i.NC_UniqueIDError is: Error 209 Ambiguous column name 'NC_Status'ThanksBryan Holmstrom
Too old to Rock'n'Roll too young to die. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-03-15 : 09:52:31
|
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. |
|
|
bholmstrom
Yak Posting Veteran
76 Posts |
Posted - 2013-03-15 : 10:15:43
|
WebFredShould 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....ThanksBryan Holmstrom |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-03-15 : 13:10:45
|
change inserted with deleted and everything is fine Too old to Rock'n'Roll too young to die. |
|
|
|
|
|