• Chrissy321 (3/8/2013)


    There are two approaches to this problem that I am aware of.

    You procedure is passed one string parameter like 'BUY','SELL','CONTRIBUTION' and then the string is split within the procedure into its individual components.

    You use a table valued parameter(TVP). Think of this as passing one parameter to the procedure but that parameter is a table containing multiple records. You take this TVP and insert into a temp table. Then you join your results to the temp table.

    This thread has some sample code I wrote that you may be able to adapt.

    http://www.sqlservercentral.com/Forums/Topic1382201-392-1.aspx#bm1382230

    Or search other articles on TVPs.

    The TVP approach would work to. However you do not need to insert into a temp table. If you pass a TVP you can just join directly to it like you would any other table.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/