Invalid object name 'updated'

So what is this error?
Thsi error occurs after I delete all the data from the branches table and then try to insert new data!
kuntaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Krishna_r19Commented:
Can you give your query?
0
tchalkovCommented:
you have a trigger on the table which has some syntax error in it. check all the triggers on your table.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dtomynCommented:
As tchalkov has said, it sounds like a trigger problem where somebody thought that since there is a Deleted and Inserted logical table that there must also be an Updated logical table... this of course is incorrect and thus at "run-time" you will get an error (you do not get an error for non-existent tables when you check the syntax since SQL Server does not worry whether or not the table exists at this syntax checking time... that is, SQL allows you to use a table that may not exist until "run-time").
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

kuntaAuthor Commented:
Here is my trigger on the branch table:

CREATE TRIGGER tr_uptBranches
ON dbo.Branch
FOR INSERT,UPDATE

AS

DECLARE @ClientID int
SELECT @ClientID = COUNT(*) FROM inserted,updated

UPDATE Client
SET BranchDetailChanged = 1
WHERE (Client.ClientID = @ClientID)

What is wrong with this?
0
dtomynCommented:
There is no such thing as an "updated" logical table.  There is an "inserted" table and a "deleted" logical table, but no updated.  Basically, for updates, there will be both a deleted and an inserted logical table that is created (before and after the update).  In your case, just get rid of the "updated" in your From clause... besides, I am not sure what the syntax that you posted would really do anyway.  If there was in fact an updated table I suppose it would give you a cartesian product?
0
kuntaAuthor Commented:
WHat the trigger is suppose to do, is when any branch details change, it will change a flag in the client table (to which the branch that was chnaged) to 1, indicating a branch belonging to that client had just had some details changed, or if there was in fact a new branch added for the client, the trigger should do the same.
0
dtomynCommented:
I am not sure if I understand your logic... SELECT Count(*) FROM Inserted will always result in 1 since the inserted logical table just contains the current record (1 row only).  All you really need to do is:
UPDATE Client
        SET BranchDetailChanged = 1
        FROM Client C
        Join Inserted I
        On C.clientid = I.clientid
       
0
kuntaAuthor Commented:
Dont worry sometimes I dont understand my logic aswell.
0
dtomynCommented:
kunta,
Did you really mean to accept tchalkov's answer instead of my comments?  I mean, I suppose tchalkov did start you in the right direction, but...
0
kuntaAuthor Commented:
Sorry dtomyn I should have accepted your answer(s), looking back that was very foolish of me not too, sorry once again.
 
0
dtomynCommented:
You could always post a 0 point question in the "EE Support" - "Experts Exchange" area.  Normally I would not mention this, but I think this is now the 4th or 5th question which someone else has received points that the questionnaire has said that I should have received.
0
kuntaAuthor Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.