How to add text before delimiter ^ in SSIS from CSV file

jn93 671 Reputation points
2022-10-19T09:34:48.747+00:00

Hi, Lets say I will received the data like below in flat file source. For each action done, they multiply it with ^. How can I tabulate this in my sql database? Anyone please help. Appreciate it.

251964-image.png

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
{count} votes

Accepted answer
  1. ZoeHui-MSFT 41,491 Reputation points
    2022-10-20T02:48:38.497+00:00

    Hi @jn93 ,

    If the length for ukey is fixed as 15, you may also use left function in SSIS.

    LEFT(ukey,15)  
    

    If the length for ukey is not fixed, you may use token function in SSIS.

    TOKEN(ukey,"^",1)  
    

    252226-image.png

    If you want to do that with T-SQL code, try with below.

    declare @ukey as nvarchar(max)='91TMIQUO6123265^91TMIQUO6123265^91TMIQUO6123265'  
    select left(@ukey, charindex('^', @ukey + '^') - 1)  
      
    or  
    declare @ukey as nvarchar(max)='91TMIQUO6123265^91TMIQUO6123265^91TMIQUO6123265'  
    select left(@ukey, 15)  
    

    252228-image.png

    Regards,

    Zoe Hui


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


1 additional answer

Sort by: Most helpful
  1. jn93 671 Reputation points
    2022-10-20T08:17:30.273+00:00

    Hi @ZoeHui-MSFT ,
    Not sure I should posted this another question or not for this. Please let me know if I should post this as another question. I will ask here because question I ask before doesn't fulfil the requirement :'(. Based on the sample file with ^ character, I have to get the desired output in table database like below. How can we achieve this using SSIS? Kindly please help.

    252372-image.png


Your answer

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