I have two tables each containing a folder path column.  These columns may contain brackets (i.e. Folder1\Folder2\Folder3[Old]\). Joining the two table columns (table1.path = table2.path) will return all records that match from each table. However, there may be a need to find partial paths from one table that exist in another - but a query using a Like operator will ignore records with brackets:
select a.*
from table1 a
cross join table2
where a.path like '%' + b.path + '%'
This does not return the correct results. Is there an escape syntax that needs to be added?
Thank you.
EDIT:
I applied Dai's syntax and it works:
select a.*
from table1 a
cross join table2
where a.path like '%' + replace(replace(b.path, '[', '#['), ']', '#]') +  '%' escape '#'
