I have tow tables in sql server 2008
TBL_CustomerMaster
[FilingId] [numeric] (18, 0) NOT NULL,
[CustId] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
TBL_Customer
[FilingId] [numeric] (18, 0) NOT NULL,
[CustUnqId] [numeric] (18, 0) NOT NULL,
[CustId] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
I used bulk insert to load data into two tables for each FilingId, CustId's for two tables are same. I have generated unique CustUnqId for TBL_Customer
Now i want to map the CustUnqId with CustId of TBL_CustomerMaster ie replace CustId in TBL_CustomerMaster with corresponding CustUnqId form TBL_Customer
kindly suggest the solution.
You can try this, but enclose this into transaction and do the testing before putting anything into production environment:
SELECT a.CustId,
b.CustUnqId
INTO #temp
FROM TBL_CustomerMaster a
JOIN TBL_Customer b ON
a.CustId = b.CustId
UPDATE TBL_CustomerMaster
SET CustId = t.CustUnqId
FROM TBL_CustomerMaster a
JOIN #temp t ON
t.CustId = a.CustId
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.