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 |
olinmds
Starting Member
25 Posts |
Posted - 2014-07-02 : 14:02:45
|
Hi all,Have two tables: table1 and table2Working with two main columns in both tables: D_ID and C_ID. Table1 has D_ID populated and C_ID is not. Table2 is a cross reference table with both D_ID and C_ID values within. Looking for best way to populate C_ID in table1 from C_ID values in table2 where table1.D_ID = table2.D_ID.There are too many values to do a case in stored procedure which has been my best practice. Trying to up my game with using SSIS 2012 as well.THANKS IN ADVANCE!!!!D |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-07-02 : 14:08:22
|
[code]UPDATE t1 SET C_ID = t2.C_IDFROM Table1 t1 INNER JOIN Table2 t2 ON t1.D_ID = t2.D_ID;[/code]If there is more than one row in Table2 for a given value of D_ID, which of the values of C_ID from among those rows will be picked for updating Table1 is unpredictable. |
 |
|
|
|
|