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 |
mikeallenbrown
Yak Posting Veteran
72 Posts |
Posted - 2014-05-17 : 09:06:38
|
I'm in need of a SQL statement that will use two fields from table A, match them to table B and then take the primary key from table B and write it to table A into the column of my choosing.I hope that wasn't too convoluted...thanks in advanceMike Brown |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2014-05-17 : 09:37:48
|
this would assume that only one row in B correlates to your two columns in A. And that you want to update your chosen column of the same row in table A rather than add a new row.I hope that wasn't too convoluted a response.update a set a.myChosenColumn = b.PKfrom tableA as ajoin tableB as b on b.col1 = a.col1 and b.col2 = a.col2 Be One with the OptimizerTG |
|
|
mikeallenbrown
Yak Posting Veteran
72 Posts |
Posted - 2014-05-17 : 17:11:02
|
That did the trick! ....thank you!!Mike Brown |
|
|
|
|
|