Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Select Where equals array

Hi

I have a list of questions in a table with an ID field that numbers them

I have to take a list of numbers that could be up to 200 long and have to selectthose questions

Using eg Select * From Questions Where ID = 4 Or ID = 5 Or ID = 33............
would be far to cumbersome.
Is there a way to use my string "4,5,33......" in the SQL statement as an array
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
declare @inputvar as varchar(max)
@inputvar='4,5,13'

select * from tablename where id in @inputvar
keyu: your suggestion is exactly NOT WORKING ...
Avatar of Murray Brown

ASKER

Thank you all