title: SQL Server 2005: Select statement in ISNULL condition
body: <p>Environment: SQL Server 2005</p>
  
  <p>I have a stored proc which receives comma separated value in one parameter. I have written a Table Valued UDF function in SQL to break it and and return me it as a table. I am using that value to filter the data in the where clause of the stored proc. Everything works fine until there is NULL in that comma separated variable passed to the stored proc. I want to write my where clause in such a way that if the variable passed is NULL then it should not use the Split function. Here is what i am doing in the stored proc.</p>
  
  <pre><code>Declare @list varchar(100), @Col2 varchar(100)
  
  SELECT  *
    FROM  Table1 t1
  INNER JOIN dbo.Table2 t2 ON t1.Col1 = t2.Col1
  WHERE t1.Col2 = ISNULL(@Col2,t1.Col2)
  --I want to write below condition the same way i have written the above condition
      AND t1.Col3 IN (select * from dbo.SplitMe(@list))
  </code></pre>
  
  <p>Is there a way to write the condition to select Col3 the way Col2 is being selected?</p>