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 |
|
ismail_issac
Starting Member
22 Posts |
Posted - 2005-11-26 : 08:37:15
|
| HiI want to update the data of perticular rows in a table to the other rows in the same table. My querry isUpdate Tab1 Set Tab1.Col1 = Tab2.Col1 , Tab1.Col2 = Tab2.Col2 from Table1 as Tab1 , Table2 as Tab2 where Tab1.Rows = 1 and Tab2.Rows = 2 and Tab1.Cols = Tab2.ColsRows Col1 , Col2 , Cols1 30 40 A1 10 20 B2 16 10 A2 5 8 BI want to update Above table with data of Rows = 1 with the values of Rows = 2so out put should be Rows Col1 , Col2 , Cols1 16 10 A1 5 8 B2 16 10 A2 5 8 BThe querry is not updating the required record. Any SuggestionsThanks In Advance |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-11-26 : 09:15:59
|
Looks OK to me, except that I would have used a JOIN.Also you are referings both "Table1" and "Table2" but you indicate that the data is all in one tableUpdate Tab1 Set Tab1.Col1 = Tab2.Col1, Tab1.Col2 = Tab2.Col2from Table1 as Tab1 JOIN Table2 as Tab2 -- Should be Table1 ?? ON Tab2.Rows = 2 AND Tab2.Cols = Tab1.Colswhere Tab1.Rows = 1 Kristen |
 |
|
|
ismail_issac
Starting Member
22 Posts |
Posted - 2005-11-26 : 09:45:14
|
| oh yes... sorry for the mistake. it should be Table1 |
 |
|
|
|
|
|