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 |
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-14 : 21:06:34
|
| Hi Experts !!I have two tables, Table A, TableB. both have same column colA. I need to update tableB ,for matching IDs (colA). table A is populated my other method.data example:table AsysID XYZID 1 100 2 110 3 120Table BSysID XYZID ** ** ** ** 1 (should populate 100)I have written a query like: insert into TableB (XYZID)select XYZID from TableA inner join TableBON TableA.sysID = TableB.sysIDThanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-07-15 : 02:14:35
|
If you want to UPDATE then don't use INSERT.UPDATE bSET XYZID = a.XYZIDFROM tableA as ajoin tableB as b on a.sysID = b.sysID No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-15 : 13:50:28
|
| Hi WebFred,It worked but its updating every other value in tableBoriginal data for AsysID XYZID1 1002 1103 1204 130But in TableB, I am gettingSysID XYZID1 NULL2 1103 NULL4 130Can you please correct the method.Thanks |
 |
|
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-07-15 : 15:07:27
|
| oh, I got it, Thanks Anyways |
 |
|
|
|
|
|