SQL006 (4/21/2016)
Thank you guysNo i am not using dynamic SQL, just passing it to storeprocedure as a parameter which is used in 'IN' operator.
one doubt does REPLACE has any performance impact.
Thanks
Based on that you're trying to do with the parameter, You either need to use dynamic sql or split the string into a table...
The following will NOT work...
DECLARE @Codes NVARCHAR(500) = N'AZJ,CLC,AZF,DDD';
DECLARE @CodesReformatted NVARCHAR(500) = CONCAT('''', REPLACE(@Codes, ',', ''','''), '''');
SELECT
*
FROM
dbo.SomeTable st
WHERE
st.Code IN (@CodesReformatted);