joining fields from two table and update to one | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

joining fields from two table and update to one

Dear Sir, i need to join three values from different table into one new table by using a condition. How should i write into store procedure? Table 1 : Cust_Dim
Fields: Cust_ID, ROC_ID Table 2 : Legal_Dim
Fields: ROC_ID, Director_Name, GRT_Name New Table : ROC_Dim
Fields : Cust_ID, ROC_ID, Director_Name, GRT_Name Remark :
1. Not all the Cust_ID in Cust_Dim are exist in ROC_Dim , if Cust_ID not exist in ROC_Dim then ignore the data. Thank you!! Onn
UPDATE rd
SET
rd.Director_Name = ld.Director_Name,
rd.GRT_Name = ld.GRT_Name
FROM
ROC_Dim rd
INNER JOIN Cust_Dim cd ON rd.Cust_ID = cd.Cust_ID
AND rd.ROD_ID = cd.ROC_ID
INNER JOIN Legal_Dim ld ON cd.ROC_ID = ld.ROC_ID
MeanOldDBA
[email protected] When life gives you a lemon, fire the DBA.
]]>