Results 1 to 2 of 2

Thread: Using a string parameter with 'IN'

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    Using a string parameter with 'IN'

    Hi
    If I write a query with
    Code:
    WHERE CODE IN ('12345,'21443','45678')
    as my selection parameters (code is a varchar) it works perfectly. I want to put this into a stored procedure so I have declared a variable @JOBLIST varchar(200). The where clause is changed to
    Code:
    WHERE CODE IN (@JOBLIST)
    and I pass to the procedure '12345','21443','45678'. It then throws an error
    A Select statement that assigns a value to a variable must not be combined with data-retrieval operations
    Any ideas how I can solve this?

    Thanks

    David

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Try with dynamic sql.

Posting Permissions

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