Results 1 to 6 of 6

Thread: VB create In Clause to pass to Stored Proc

  1. #1

    Thread Starter
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681

    VB create In Clause to pass to Stored Proc

    I have VB create a Where clause that I want to pass to a stored procedure in SQL Server.

    For example, @myParameter that I am passing in is ("A", "B", "C") and I want to say in my stored proc: Where item IN @myParameter.

    Is this possible? It only seems to think that @myParameter is a single item and tries to match the whole string ("A", "B", "C") instead of "A" or "B" or "C".

    Any suggestions?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Huh? It seems like you are trying to pass three values to the same parameter. I think I must have missed something.

  3. #3

    Thread Starter
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    I am trying to pass the string that I want to be used in the WHERE IN clause.

    WHERE IN (my parameter value here)

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I was stuck with the same issue in access queries. What i did was rebuilding the query in the code. But it does not seem to be a wise solution for Stored Proc.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I always thought that stored proceedure parameters won't allow that because of SQL Injection attacks. If you think about it, lets say someone specified a parameter of:

    ;DELETE * FROM Users;

    Your parameter would now look like this:
    WHERE IN 'A' ;DELETE * FROM Users; 'B'

    .... So SQL parameters won't allow that.

    What you can do is either run the statement using a regular sql statement without SP's, or provide enough parameters for all the options you need, then use If statements and what not to get the desired effect inside the SP.

  6. #6
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    You may look at here for possible answer:
    http://www.algonet.se/~sommar/arrays-in-sql.html
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width