Null Or Multiple Parameters When Querying I have a stored procedure that has a parameter that must take a comma delimited varchar list of values that can be turned into a table of values or can be NULL, such as

@Values VARCHAR(10) = NULL


OR

@Values VARCHAR(10) = '1,5,10' 

IF OBJECT_ID('TEMPDB..#Parameters') IS NOT NULL DROP TABLE #Parameters
CREATE TABLE #Parameters ( Id INT )

INSERT INTO #Parameters
SELECT
    [Value]
FROM
    FunctionThatReturnsStringToTable(',',@Values)


I need to figure out a way to make this work in SQL like so

SELECT
   SomeColumns
FROM
   TABLE
WHERE
   COLUMN = IIF(@Values IS NULL, COLUMN, (SELECT Id FROM #Parameters)


Which I know will not work. Is there any other way around this?
You can do it this way (notice this avoids the unnecessary #temp table):

SELECT SomeColumns
FROM dbo.TABLE AS t
LEFT OUTER JOIN dbo.FunctionName(',',@Values) AS p
ON t.COLUMN = p.Value
WHERE t.COLUMN = CASE WHEN @Values IS NULL THEN t.COLUMN ELSE p.Value END;


But much, much, much better to pass @Values as a TVP instead of a string you have to split.

No idea what your split function actually looks like, but have a look at these posts:

http://sqlperformance.com/2012/07/t-sql-queries/split-strings

http://sqlperformance.com/2012/08/t-sql-queries/splitting-strings-now-with-less-t-sql