Like

Why would the following syntax still returns records with field value "advance_directives_information_id"

WHERE C1.Name LIKE '%Form_%'

declare @tbl table
( name  varchar(499)
)


insert into @tbl(name)
values('advance_directives_information_id')

select *
from @tbl as c1
where c1.name LIKE '%Form_%'

select *
from @tbl as c1
where c1.name LIKE '%Form!_%' ESCAPE '!'

output1:

name
advance_directives_information_id

output2:

name
No rows returned

because character _ it's wildcard character , and if you want to use like a regular character use ESCAPE

dbfiddle

1 Like