Parsing an ADO result set into a comma separated string in SSIS

  • Comments posted to this topic are about the item Parsing an ADO result set into a comma separated string in SSIS

  • I would rather build the CSV using SQL at first place

  • I'm a bit torn on this one...

    The article is nicely written with good clear graphics examples but I just wouldn't do this task this way. On the other hand, if you look deeper, there are some decent techniques shown that could be used for other things in the future.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Hi There,

    The reason we wanted to do this in SSIS was because we pull data from a lot of various sources in our data warehouse and instead of relying on SQL logic which could have varied by database server or version, I wanted to do this on our ETL side of things.

    Thanks!

    Garima

    http://edw.northwestern.edu

  • This is a good article, and your explanation as to why you did this in SSIS is a great example of how "best" practices sometimes are NOT the best solution for a particular business need.

    hr_sn, I expect we'll see your article on how to do this in T-SQL soon? 😛

  • Jeff Moden (9/1/2010)


    I'm a bit torn on this one...

    The article is nicely written with good clear graphics examples but I just wouldn't do this task this way. On the other hand, if you look deeper, there are some decent techniques shown that could be used for other things in the future.

    I agree.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Nice article and i would use the same technique in a DW environments when i have to pull information from different sources. But would be curious to see alternate methods to accomplish this, if any.

    Thanks,

    Amol Naik

  • sknox (9/1/2010)


    .... your explanation as to why you did this in SSIS is a great example of how "best" practices sometimes are NOT the best solution for a particular business need.

    By no stretch of the imagination is the way this task was accomplished in the article the "best" way to do this even for "particular" business needs. I also state that "Business needs" should never stipulate "how" within the realm of data processing once the data is inside the server with the possible exception of what is required security wise.

    Further, what business needs? The author simply stated "I recently had a need to build a package... " and that's quite far from anything known as a "particular business need".

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Jeff Moden (9/1/2010)


    sknox (9/1/2010)


    .... your explanation as to why you did this in SSIS is a great example of how "best" practices sometimes are NOT the best solution for a particular business need.

    By no stretch of the imagination is the way this task was accomplished in the article the "best" way to do this even for "particular" business needs. I also state that "Business needs" should never stipulate "how" within the realm of data processing once the data is inside the server with the possible exception of what is required security wise.

    Further, what business needs? The author simply stated "I recently had a need to build a package... " and that's quite far from anything known as a "particular business need".

    Hiya Jeff,

    I hate to speak for someone else but I think what skonx may have referenced as my business need was based on my first reply. One thing that I do agree with is that this isn't necessarily the "Best" solution but as I mentioned at the start of my article, "I wanted to see if there were other ways to do simple programming using simple SSIS control flow components". This was more of an exploratory mission aiming to see what kind of fun things we can do with SSIS. It was a fun exercise that I thought was worth sharing. 🙂

    Cheers,

    Garima

  • sknox (9/1/2010)

    hr_sn, I expect we'll see your article on how to do this in T-SQL soon? 😛

    There's already so many article available to create CSV using SQL and IMO no need of one more, you just need to use search on this site.

  • Hello,

    try this select (this pivots rows to one string row):

    select stuff((select top 10 ',"' + code + '"' from Products order by code for XML path('')), 1, 1, '');

  • Hi. I have tried to following your example posted here verbatim, however, whenever I execute my package it fails on the Execute SQL Task within the Foreach loop. I get the following error

    "Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query ""SELECT '"+@[User::FileList]+","+@[User::MissingFi..." failed with the following error: "Incorrect syntax near '+'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    Task failed: Execute SQL Task"

    What should I look for that I may have overlooked earlier?

    My variables

    name datatype value

    sql_str String "SELECT '"+@[User::FileList]+", "+@[User::MissingFileName]+'" as FileList"

    MissingFiles Object

    MissingFileName String

    FileList String

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply