user1399377
user1399377

Reputation: 479

SQL Server- search is not working for the square bracket

I have a table tblEmpl which has a column employeename. In that employee name column I have a row with a value of John [Smith] so I have a query to search the row but it is not selecting any row.

select * from tblEmpl 
where EmployeeName like '%John [Smith]%'

Thanks

Upvotes: 1

Views: 2288

Answers (3)

praveen
praveen

Reputation: 12271

Try this :

select * from tblEmpl where EmployeeName like '%John [[]Smith]%'

Upvotes: 2

Yograj Gupta
Yograj Gupta

Reputation: 9869

Try This

select * from tblEmpl where EmployeeName like '%John [[Smith]%'

Just replace [ to [[.

Upvotes: 1

anon
anon

Reputation:

WHERE EmployeeName LIKE '%John \[Smith\]%' ESCAPE '\';

or

WHERE EmployeeName LIKE '%John [[]Smith]%';

Upvotes: 6

Related Questions