Sql where statement with = works but LIKE does not Is there a fix for this?
Here is the exact code:
create table zSyn (xField nvarchar(255)); insert into zSyn(xField) select 'DEVCON 5 Minute Epoxy amber [1:1]'; --Works and returns 1 row: select * from zSyn where xField = 'DEVCON 5 Minute Epoxy amber [1:1]'; --Does NOT return any rows: select * from zSyn where xField like '%' + 'DEVCON 5 Minute Epoxy amber [1:1]' + '%'
Advertisement
Answer
You need to escape []
:
select * from zSyn where xField like ('%' + 'DEVCON 5 Minute Epoxy amber ![1:1!]' + '%') ESCAPE '!';