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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 update a table from a different table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-22 : 06:56:28
andrea writes "I'm trying to update a column in one table with data from a different table. This is the query I wrote (which doesn't work).

UPDATE authors JOIN masterauthorlist on
(authors.email = masterauthorlist.email)
SET authors.fullname = masterauthorlist.fullname;

What am I doing wrong?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-08-22 : 06:58:18
Pretty close, SQL Server has a somewhat odd syntax for this:

UPDATE authors
FROM authors JOIN masterauthorlist on
(authors.email = masterauthorlist.email)
SET authors.fullname = masterauthorlist.fullname;


When doing a JOIN in an UPDATE or DELETE you must specify a FROM clause with the JOIN condition(s).
Go to Top of Page

kapilarya
Yak Posting Veteran

86 Posts

Posted - 2005-08-23 : 01:35:50
TRY THIS :
UPDATE authors
SET authors.fullname = masterauthorlist.fullname
FROM masterauthorlist
WHERE (authors.email = masterauthorlist.email)


Kapil Arya
Go to Top of Page
   

- Advertisement -