If only one value is passed, for example '2565' then query works fine. I am not sure what am I missing. OR if I should use some other function besides INDEX. Basically, in simple words what I am trying to achieve is:

Re: INDEX function

Ulrich,

'''2565'',''5216'',''5364''' did not work. Data type of Group_ID is int.

IN clause was the first thing I tried. It works if I pass hard coded values, but if I pass values as variable @Group it did not work. I guess it is adding extra quotes around it. What I mean is if I try

WHERE Group_ID IN ('2445','1452'), it works, but when I pass @Group, WHERE Group_ID in (@Group), it converts to WHERE Group_ID IN (''2445','1452'') adding extra quotes and does not return anything. Can you suggest any solution to this? Or if you can suggest any other function which might work in this situation.

Re: INDEX function

I don't think we can be any more specific until we understand what "I am passing a variable from SQL server through a process" means. What is the process? What doe it mean that it is from SQL Server? Are you actually executing this in SQL Server? If so, then you have to edit @GroupID to remove the quotes as discussed previously, and construct the SQL statement as a string to be dynamically executed.