May 26, 2008 at 2:33 pm
:cool:Not sure why this is happening --- hoping someone can help me with this very simple coding issue:
I'm trying to update my company table with a member table field. Here is the code:
UPDATE Company
SET t.comp_mypassword = s.password
FROM Company t, Members s
WHERE t.comp_oldContactID = s.ContactID
AND t.comp_oldAddrID = s.AddrID
I keep getting the following error code:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "t.comp_mypassword" could not be bound.
Please help.
Thanks,
Steph
May 26, 2008 at 3:15 pm
Try this:
UPDATE t
SET t.comp_mypassword = s.password
FROM Company t, Members s
WHERE t.comp_oldContactID = s.ContactID
AND t.comp_oldAddrID = s.AddrID
Manu
May 26, 2008 at 3:18 pm
great - thanks.
Steph
September 17, 2008 at 11:20 am
MANU (5/26/2008)
Try this:UPDATE t
SET t.comp_mypassword = s.password
FROM Company t, Members s
WHERE t.comp_oldContactID = s.ContactID
AND t.comp_oldAddrID = s.AddrID
Manu
Manu, I just ran into this exact situation with my first installation of SQL 2008. What's the deal? I went through BOL and didn't see an example of updating the alias instead of the table name. Where did you learn about this syntax change?
-----
[font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]
September 17, 2008 at 12:19 pm
stephane (5/26/2008)
:cool:Not sure why this is happening --- hoping someone can help me with this very simple coding issue:I'm trying to update my company table with a member table field. Here is the code:
UPDATE Company
SET t.comp_mypassword = s.password
FROM Company t, Members s
WHERE t.comp_oldContactID = s.ContactID
AND t.comp_oldAddrID = s.AddrID
I keep getting the following error code:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "t.comp_mypassword" could not be bound.
Please help.
Thanks,
Steph
I think the real reason is you're updating Company but settig t.comp_mypassword. t is the alias used in your from clause. Just a quick pass (meaning untested) but the below should work for you as well.
UPDATE Company
SET comp_mypassword = s.password
FROM Company t
inner join Members s
on t.comp_oldContactID = s.ContactID
AND t.comp_oldAddrID = s.AddrID
-- You can't be late until you show up.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply