Question: I want to pass multiple values in a single parameter. SQL Server 2005

Answer: 
You *can* make a function:

```
ALTER  FUNCTION [dbo].[CSVStringsToTable_fn] ( @array VARCHAR(8000) )
RETURNS @Table TABLE ( value VARCHAR(100) )
AS 
    BEGIN
        DECLARE @separator_position INTEGER,
            @array_value VARCHAR(8000)  

        SET @array = @array + ','

        WHILE PATINDEX('%,%', @array) <> 0 
            BEGIN
                SELECT  @separator_position = PATINDEX('%,%', @array)
                SELECT  @array_value = LEFT(@array, @separator_position - 1)

                INSERT  @Table
                VALUES  ( @array_value )

                SELECT  @array = STUFF(@array, 1, @separator_position, '')
            END
        RETURN
    END

```

and select from it:

```
DECLARE @LocationList VARCHAR(1000)
SET @LocationList = '1,32'

SELECT  Locations 
FROM    table
WHERE   LocationID IN ( SELECT   CAST(value AS INT)
                           FROM     dbo.CSVStringsToTable_fn(@LocationList) )

```

OR

```
SELECT  Locations
FROM    table loc
        INNER JOIN dbo.CSVStringsToTable_fn(@LocationList) list
            ON CAST(list.value AS INT) = loc.LocationID

```

Which is extremely helpful when you attempt to send a multi-value list from SSRS to a PROC.

**Edited:** to show that you may need to CAST - However be careful to control what is sent in the CSV list
There are multiple ways you can achieve this, by:

1. **Passing CSV list** of strings as an argument to a (N)VARCHAR parameter, then parsing it inside your SP, [check here](http://sqlwithmanoj.com/2012/09/09/passing-multipledynamic-values-to-stored-procedures-functions-part1-by-passing-csv/).
2. Create a **XML string** first of all, then pass it as an XML datatype param. You will need to parse the XML inside the SP, you may need APPLY operator for this, [check here](http://sqlwithmanoj.com/2012/09/09/passing-multipledynamic-values-to-stored-procedures-functions-part2-by-passing-xml/).
3. Create a **temp table** outside the SP, insert the multiple values as multiple rows, no param needed here. Then inside the SP use the temp table, [check here](http://sqlwithmanoj.com/2012/09/09/passing-multipledynamic-values-to-stored-procedures-functions-part3-by-using-table/).
4. If you are in 2008 and above try **TVPs (Table Valued Parameters)** and pass them as params, [check here](http://sqlwithmanoj.com/2012/09/10/passing-multipledynamic-values-to-stored-procedures-functions-part4-by-using-tvp/).