Help to complete in statement

  • In a store procedure will get value from application for member ID like

    '12456', '88997'...

    How to complete store procedure in where statement below

    where [MEMBER ID] IN ( @myID )

    @myID = '12456', '88997'

  • adonetok (9/10/2015)


    In a store procedure will get value from application for member ID like

    '12456', '88997'...

    How to complete store procedure in where statement below

    where [MEMBER ID] IN ( @myID )

    @myID = '12456', '88997'

    Use the function DelimitedSplit8k[/url] to split the string into rows and columns. You could save the result as a table, inline as a CTE or use IN.

    EDIT: speling.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • What Chris is saying is, you can't just reference the parameter value like that unless you change it to a table valued parameter and then do a SELECT or JOIN to it. You have to break the information down as he suggested, or change the approach.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

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

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