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

  • Garima Sharma

    SSC Veteran

    Points: 243

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

  • hr_sn

    Ten Centuries

    Points: 1062

    I would rather build the CSV using SQL at first place

  • Jeff Moden

    SSC Guru

    Points: 995662

    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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "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)

  • Garima Sharma

    SSC Veteran

    Points: 243

    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

  • sknox

    SSChampion

    Points: 12284

    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? 😛

  • Alvin Ramard

    SSC-Forever

    Points: 41190

    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]

  • AmolNaik

    SSCarpal Tunnel

    Points: 4767

    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

  • Jeff Moden

    SSC Guru

    Points: 995662

    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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "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)

  • Garima Sharma

    SSC Veteran

    Points: 243

    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

  • hr_sn

    Ten Centuries

    Points: 1062

    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.

  • petr.novak

    Grasshopper

    Points: 13

    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, '');

  • stephen.bray

    Newbie

    Points: 5

    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 12 (of 12 total)

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