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 |
rdev.theo
Starting Member
5 Posts |
Posted - 2011-07-19 : 14:54:43
|
Hi, I have 2 tables which have one common field, I need to ensure that few rows are updated as in table 1 in table 2:for eg:Table 1Common_Field Name1234 Chandan4321 KiranTable 2Common_Field Name1234 Raj4321 KiranIntended Result:Common_Field Name1234 Chandan4321 KiranPlease let me know, Thanks |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-07-19 : 15:00:02
|
So the Name in table2 should be updated to the Name of table1 if Common_field is matching and Names are different?Try:update t2set Name = t1.Namefrom table2 as t2join table1 as t1 on t1.Common_Field = t2.Common_Field where t2.Name <> t1.Name No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
rdev.theo
Starting Member
5 Posts |
Posted - 2011-07-19 : 15:55:48
|
Yes what you have understood is correct...Tried following I get and error as "SQL command not properly ended"any reasons? |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-07-19 : 17:12:47
|
Oh!You have posted in a MS SQL Server forum but the error is ORACLE, so I dont know.Please try http://www.dbforums.com/oracle/ No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|