my first post here .. sorry for the lack of formatting
I had a performance issue as shown below:
90sec: WHERE [Column] LIKE (Select [Value] From [Table])
// Dynamic, Slow
1sec: WHERE [Column] LIKE ('A','B','C')
// Hard, fast
1sec: WHERE @CSV like CONCAT('%',[Column],'%')
// Solution below
I tried to join, not request.
I also tried using CTE in hard code.
I finally tried the temporary table.
None of these standard options worked, and I did not want to use the dosp_execute option.
The only solution that worked like:
DECLARE @CSV nvarchar(max) = Select STRING_AGG([Value],',') From [Table]; // This yields @CSV = 'A,B,C' ... WHERE @CSV LIKE CONCAT('%',[Column],'%')
source share