Passing a parameter with multiple values to an SP

  • I have a report in which they want a parameter field to be text entry (not a drop pick list!) where a user can enter multiple values for an item no.

    So for instance they need to go in and enter

    55-102, 54-5677, 32-222

    or

    55-102

    or

    55-490,54-094

    etc.

    in my sp I am passing the param as

    Where sd.item_num in (@ItemNo)

    This works for just one parameter but I figure it's reading the

    55-102, 54-5677, 32-222

    or

    55-102

    as one string.

    Is there a way around this?

  • The best way to handle this is to split the parameter passed in and put the values into a table or use a table-valued function and then join on the results. On SSC the consensus fastest way to split a string is to use a numbers or tally table. Jeff Moden has written a great article[/url] on this that you should read.

Viewing 2 posts - 1 through 1 (of 1 total)

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