I need to escape [ in an sql query for SQL Server
select * from sometable where name like \'[something]\';
I actually am looking for a [ be
Embed the [ in []
[
[]
declare @T table ( name varchar(20) ) insert into @T values ('abc'), ('[abc') select * from @T where name like '[[]a%'
Result:
name -------------------- [abc
Have a look here at what you can do in the like expression. LIKE (Transact-SQL)
like