Stored Procedure that uses a parameter in a WHERE x IN(@param1)

  • CELKO (11/21/2016)


    If you want to have a set of scaler values in a query, then you need to put them in a table or a table constructor.

    The OP is asking how to do this. You didn't help and obviously you didn't take some time to read the thread.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Budd (11/21/2016)


    Eirikur Eiriksson (11/20/2016)


    Budd (11/18/2016)


    WOW!!!

    So very many possibilities, and so much to consider..

    Quick questions, can you use Table Variable Parameter? How wide are the largest values passed? How many values at the most would be passed? Have you thought of using dynamic SQL?

    😎

    Quick Answers;

    Probably, had not attempted that.

    12 at most.

    Dynamic SQL is always my last resort.

    How wide are the largest values passed? Are all the values of similar length?

    😎

    Dynamic SQL could be the best option if done correctly, obviously depending on the type of values passed and how the values are used in the procedure. Have seen huge performance improvements when changing from splitting functions to dynamic SQL but as I said, it depends.

    Further, fixed length parameters are easier and much faster to split than variable length parameters, almost by the factor of the length of the parameters.

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

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