Passing a Multi-Value Parameter into an OPENQUERY

  • I'm trying to query a table of about 120,000 records using OPENQUERY. We will call the table "Person". For this table, there are multiple statuses, such as, "Active", "Discharged", "Resigned", etc. I have a parameter, @status, which is a multi-value parameter and needs to be passed to the OPENQUERY, so I can limit the amount of records coming into the dataset. Here's an example of what I'm looking for:

    SELECT * FROM OPENQUERY(DATA_WAREHOUSE,'SELECT PersonID, EmploymentStatus FROM dbo.Employee WHERE EmploymentStatus IN [@Status parameter goes here...]')

    I have tried the following (after reading some other forum entries) which have not worked:

    ...IN '''@Status'''')

    ...IN ''' + @status'''')

    ...IN ''' + @status + '''')

  • Hello, after doing some more research into this, still haven't come up with a good solution. Anyone have any good ideas for this?

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

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