IN condition is not working in Stored procedure

  • Hi,

    I am passing comma seperated values to SP where i am using IN in the where condition, but its not displaying query results.

    Please give me a solution

    Thanks,

    Prabha

  • prabhakaran.ece (11/5/2008)


    Hi,

    I am passing comma seperated values to SP where i am using IN in the where condition, but its not displaying query results.

    Please give me a solution

    Thanks,

    Prabha

    Use dynamic queries or let me know the query you are using

    kshitij kumar
    kshitij@krayknot.com
    www.krayknot.com

  • Instead of using dynamic SQL, you can transform the list of values ( 'a, b, c, ... ') into a Table, and then make a JOIN.

    Something like this:

    select f1, f2, f3,

    from YourTable,

    fn_Transform(@paramListOfValues) as Values

    WHERE YourTable.field = Values.field

    There are a lot of articles about this idea in this website and in the www.

    For example:

    http://qa.sqlservercentral.com/articles/T-SQL/63003/

    You can make searchs with these words:

    'Array in SQL'

    'Tally Table'

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

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