I want to use a clause along the lines of \"CASE WHEN ... THEN 1 ELSE 0 END\" in a select statement. The tricky part is that I need it to work with \"value IN @List\".
This might be along the lines of what you need.
Note that this assumes that you have permissions and the input data has been sanitized.
From Running Dynamic Stored Procedures
CREATE PROCEDURE MyProc (@WHEREClause varchar(255))
AS
-- Create a variable @SQLStatement
DECLARE @SQLStatement varchar(255)
-- Enter the dynamic SQL statement into the
-- variable @SQLStatement
SELECT @SQLStatement = "SELECT * FROM TableName WHERE " + @WHEREClause
-- Execute the SQL statement
EXEC(@SQLStatement)