Use the Sql bracket ([ ]) or forward slash (\) when used with the special character.
Eg:
SELECT columns FROM table WHERE
column LIKE '%[%]%'
column LIKE '%[%]%'
[or]
SELECT columns FROM table WHERE
column LIKE '%\%%' ESCAPE '\
column LIKE '%\%%' ESCAPE '\
How to escape the square bracket itself
SELECT columns FROM table WHERE
column LIKE '%[[]SQL Server Driver]%'
column LIKE '%[[]SQL Server Driver]%'
[or]
SELECT columns FROM table WHERE
column LIKE '%\[SQL Server Driver]%' ESCAPE '\'
column LIKE '%\[SQL Server Driver]%' ESCAPE '\'
Source:
http://sqlserver2000.databases.aspfaq.com/how-do-i-search-for-special-characters-e-g-in-sql-server.html
No comments:
Post a Comment