I am trying to create the answer
SELECT *
FROM table
WHERE column LIKE 'Text%'
OR column LIKE 'Hello%'
OR column LIKE 'That%'
in below link:
Combining "LIKE" and "IN" for SQL Server
The problem is, in my example the values in the answer 'Text', 'Hello' and 'That' are not hard coded, they are populated from an application multi-select control and can be NULL
value or a comma-separated string like this :
DECLARE @String_With_Commas nvarchar(255);
SET @String_With_Commas = N'Mercedes,BMW,Audi,Tesla,Land Rover';
I have tried below code, but it didn't work :
DECLARE @SearchString = CONCAT('''',REPLACE(@String_With_Commas, N',', N'%'' OR column LIKE '''));
And use it like :
WHERE column LIKE @SearchString + '%' + ''''