Aleks
asked on
Update SQL
I am trying to update the value of a field in one table to be that of another field on the same DB but from another table when the ids are the same.
I will be using the query in other databases so I want to include the database name in it. Here is the query. I get an error that the object is invalid or that the object cannot be bound. I double checked the names and they are correct. But there must be a syntax error:
I will be using the query in other databases so I want to include the database name in it. Here is the query. I get an error that the object is invalid or that the object cannot be bound. I double checked the names and they are correct. But there must be a syntax error:
UPDATE [BDotSostrinImmigration].[dbo.Users]
SET [BDotSostrinImmigration].[dbo.users].[MailCareOf] = [BDotSostrinImmigration].[dbo.zzzBDotAddressesHome].[ResCareOf]
WHERE [BDotSostrinImmigration].[dbo.Users].[trackeruserid] = [BDotSostrinImmigration].[dbo.zzzBDotAddressesHome].[IndivID]
AND [BDotSostrinImmigration].[dbo.zzzBDotAddressesHome].[imported] =1
ASKER
Part of it seems to work but even thought the fields are there and the names are correct I get this error:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "BDotSostrinImmigration.db o.zzzBDotA ddressesHo me.IndivID " could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "BDotSostrinImmigration.db o.zzzBDotA ddressesHo me.importe d" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "BDotSostrinImmigration.db
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "BDotSostrinImmigration.db
ASKER
I don't understand why this is happening. But I can run this query and it returns the results:
But when I run the update it marks: [BDotSostrinImmigration].[ dbo].[zzzB DotAddress esHome].[R esCareOf] in red and says that it cannot be bound ???
This is the query as I have it:
SELECT [BDotSostrinImmigration].[dbo].[zzzBDotAddressesHome].[ResCareOf]
FROM [BDotSostrinImmigration].[dbo].[zzzBDotAddressesHome]
But when I run the update it marks: [BDotSostrinImmigration].[
This is the query as I have it:
UPDATE [BDotSostrinImmigration].[dbo].[Users]
SET [BDotSostrinImmigration].[dbo].[users].[MailCareOf] = [BDotSostrinImmigration].[dbo].[zzzBDotAddressesHome].[ResCareOf]
WHERE [BDotSostrinImmigration].[dbo].[Users].[trackeruserid] = [BDotSostrinImmigration].[dbo].[zzzBDotAddressesHome].[IndivID]
AND [BDotSostrinImmigration].[dbo].[zzzBDotAddressesHome].[imported] =1
ASKER
I even tried something simpler, like this:
But it says that:
Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "zzzBDotAddressesHome.Indi vID" could not be bound.
What does that mean ?
UPDATE dbo.Users
SET Users.MailCareOf = zzzBDotAddressesHome.ResCareOf
WHERE Users.trackeruserid = zzzBDotAddressesHome.IndivID
But it says that:
Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "zzzBDotAddressesHome.Indi
What does that mean ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This works !
].[dbo.Users]
to
].[dbo].[Users]
everywhere:
Open in new window