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 Multiple Rows in Table

Author  Topic 

Chap
Starting Member

30 Posts

Posted - 2010-02-04 : 16:02:15
How do I update a column in a table from a column in another table? The update set = returns "Subquery returned more than 1 value......"
There are multiple rows joining on id.

George

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-02-04 : 16:10:05
Here's an example:

UPDATE t1
SET Column2 = t2.Column2
FROM Table1 t1
JOIN Table2 t2
ON t1.Column1 = t2.Column1
WHERE ...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

Chap
Starting Member

30 Posts

Posted - 2010-02-09 : 13:52:26
Thank you Tara, it seems so simple. I guess I was trying to make to much of it, you query worked great.

Thanks
George

George
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-09 : 13:55:43
you need to make sure relation b/w Table1 & Table2 is 1 to 1 else it can result in random update
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-02-09 : 20:07:58
You're welcome, George.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -