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.
| Author |
Topic |
|
QAZAFI
Yak Posting Veteran
50 Posts |
Posted - 2008-05-15 : 01:13:12
|
| I am in a situation in which I would like to update my one table three column with other table three column, The other table might have more then one record but I would like to have the TOP 1 record of that table for these column. How can I achive it. I know I will be able to achive by writing three statment likeUpdate abcset a=(select top 1 a from xyz order by ),b=( select top 1 b from xyz) and so but not sure that a and b using the same record and thats the requirment of update is any help much apprecited |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-15 : 01:17:46
|
| UPDATE aSET Column1 = b.Column1, Column2 = b.Column2FROM Table1 aINNER JOIN (SELECT TOP 1 YourPK, Column1, Column2 FROM Table2 ORDER BY YourPK) bON a.YourPK = b.YourPKTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
|
|
|