?
Solved

Invalid object name 'updated'

Posted on 1999-12-16
12
Medium Priority
?
1,577 Views
Last Modified: 2012-06-27
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!
0
Comment
Question by:kunta
12 Comments
 

Expert Comment

by:Krishna_r19
ID: 2289009
Can you give your query?
0
 
LVL 7

Accepted Solution

by:
tchalkov earned 200 total points
ID: 2289163
you have a trigger on the table which has some syntax error in it. check all the triggers on your table.
0
 
LVL 5

Expert Comment

by:dtomyn
ID: 2290584
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
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 

Author Comment

by:kunta
ID: 2293525
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
 
LVL 5

Expert Comment

by:dtomyn
ID: 2293639
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
 

Author Comment

by:kunta
ID: 2293646
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
 
LVL 5

Expert Comment

by:dtomyn
ID: 2293925
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
 

Author Comment

by:kunta
ID: 2293945
Dont worry sometimes I dont understand my logic aswell.
0
 
LVL 5

Expert Comment

by:dtomyn
ID: 2293980
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
 

Author Comment

by:kunta
ID: 2293991
Sorry dtomyn I should have accepted your answer(s), looking back that was very foolish of me not too, sorry once again.
 
0
 
LVL 5

Expert Comment

by:dtomyn
ID: 2294003
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question