Share via

SSIS -Insert missing records from existing record

Anonymous
2021-07-01T12:39:11.577+00:00

I am new to SSIS. have a SSIS package to load the below data from another source to a SQL Table. The data shows the exchange rate values for currency conversion. This rate exists for AUD/INR however it is missing for INR/AUD. I need to calculate the inverse of the missing rate by coping the exiting one and taking the rate 1/exchange rate I used @Reza Raad's thread/exchange rates to explain the change I need to do

Current results:
Customer_Currency Local_Currency Effective_Date Exchange_Rate
AUD INR 2011-03-29 45.85
AUD INR 2011-03-28 45.91
AUD INR 2011-03-26 45.50
AUD INR 2011-03-25 45.39

Expected Results:

Customer_Currency Local_Currency Effective_Date Exchange_Rate
INR AUD 2011-03-29 1/45.85 = 0.022
INR AUD 2011-03-28 1/ 45.91
INR AUD 2011-03-26 1/ 45.50
INR AUD 2011-03-25 1/45.39
AUD INR 2011-03-29 45.85
AUD INR 2011-03-28 45.91
AUD INR 2011-03-26 45.50
AUD INR 2011-03-25 45.39

SQL Server Integration Services
0 comments No comments

2 answers

Sort by: Most helpful
  1. EchoLiu-MSFT 14,626 Reputation points
    2021-07-06T06:06:58.547+00:00

    Please refer to the tsql method:

    CREATE TABLE #test(Customer_Currency char(15),Local_Currency char(15),  
    Effective_Date date,Exchange_Rate decimal(4,2))  
    INSERT INTO #test VALUES('AUD','INR','2011-03-29',45.85),  
                            ('AUD','INR','2011-03-28',45.91),  
     ('AUD','INR','2011-03-26',45.50),  
     ('AUD','INR','2011-03-25',45.39)  
      
    SELECT * FROM #test  
      
    SELECT Local_Currency as Customer_Currency,Customer_Currency as Local_Currency,  
    Effective_Date,CAST(1/Exchange_Rate AS DECIMAL(4,3))  
    FROM #test  
    UNION ALL  
    SELECT * FROM #test  
    

    Output:
    112032-image.png

    If you have any question, please feel free to let me know.

    Regards
    Echo


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Was this answer helpful?

    0 comments No comments

  2. EchoLiu-MSFT 14,626 Reputation points
    2021-07-02T05:49:39.2+00:00

    Hi anonymous user,

    Is your source also a SQL table? If so,please share us your table structure (CREATE TABLE …) and some sample data(INSERT INTO …).

    If not, please share your source data. For us to test.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.