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 Query

Author  Topic 

t1g312
Posting Yak Master

148 Posts

Posted - 2004-12-26 : 05:18:29
Hi all,

Can I write a query to update fields in a row using values from another row in the same table?

Thanks

Adi

-------------------------
/me sux @sql server

Kristen
Test

22859 Posts

Posted - 2004-12-26 : 05:50:30
Yes. Something like:

UPDATE U
SET U.MyColumn = X.SomeColumn
FROM MyTable U
JOIN MyTable X
ON U.AColumn = X.AnotherCoumn
AND U.ABC = X.XYZ

Kristen
Go to Top of Page

t1g312
Posting Yak Master

148 Posts

Posted - 2004-12-26 : 06:12:13
quote:
Originally posted by Kristen

Yes. Something like:

UPDATE U
SET U.MyColumn = X.SomeColumn
FROM MyTable U
JOIN MyTable X
ON U.AColumn = X.AnotherCoumn
AND U.ABC = X.XYZ

Kristen



Thanks Kristen!

Adi

-------------------------
/me sux @sql server
Go to Top of Page
   

- Advertisement -