I am trying to create a stored procedure in SQL Server 2008 where I am trying to replicate a simple query of
SELECT Col1, Col2
FROM Table
WHERE Col1 LIKE 'A%'
OR Col1 LIKE 'B%'
OR Col1 LIKE 'C%'
as
CREATE PROCEDURE usp_MySP
@ColValues varchar(100) = NULL
AS
SELECT Col1, Col2
FROM Table
WHERE (@ColValues IS NULL OR Col1 LIKE (????))
Unable to replace ??. Basically I want to use LIKE with IN / OR. Any help?
If the number of parameters is unknown, then you will need to do a table operation. Basically something like
In order to generate table
MyParameters, you can either construct it in your code, or use the new table-valued parameters in 2008.