开发者

Moving data in one table to another table Based on condition

I need help in figuring out the solution for my problem.

1. I have a 4 tables

a. CLientdetails
b. ClientAccountDetails
c. ClientExistingData
d. ClientNotExistindata.

Clinet details contains data related to the name of the client, startingdate, endingDate

ClientAccountDetails contains data related to specific client(ie multiple accounts asscoiated with his name, status of the account, money)

using SSIS package i import data from Excel sheet(data related to excel sheet is of ClientAccountDetails) into a different table called IMPORTClientDetails.

when all the data gets imported to the table using ssis package. i would write some query to move that into the ClientAccountDetails table based on the Name of the Clien开发者_运维技巧t.

2. My question is

If the Client name from IMPORTClientDetails doesnot exist in the ClientDetails table i want the data to be moved to ClientNotExistindata

if the Client name from IMPORTClientDetails exist then i want to move that into ClientAccountDetails


This can be done with two simple INSERT/SELECT statements.

INSERT INTO ClientAccountDetails(COLUMN1,COLUMN2, ETC)
SELECT COLUMN3,COLUMN4, ETC
FROM IMPORTClientDetails ICD
WHERE ICD.Client IN (SELECT Client FROM ClientDetails);

INSERT INTO ClientNotExistindata(COLUMN1,COLUMN2, ETC)
SELECT COLUMN3,COLUMN4, ETC
FROM IMPORTClientDetails ICD
WHERE ICD.Client NOT IN (SELECT Client FROM ClientDetails);


In SSIS you can use the Lookup Task to check if the imported ClientName rows from IMPORTClientDetails exist in ClientDetails - if there is no match, they can be sent to ClientNotExistindata. The matching rows can then be sent to ClientAccountDetails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜