How to deal with queires which contain square brackets?

P

Peijun

I have to search my database with a query containing square brackets. How can
I escape it?

Thanks in advance,

Peijun Zhang
 
C

Clifford Bass

Hi,

Try any of these:

Opening bracket:

select * from tblSomeTable where SomeField like "*[[]*";

Closing bracket:

select * from tblSomeTable where SomeField like "*]*";

Opening bracket followed by a closing bracke:

select * from tblSomeTable where SomeField like "*[[]*]*";

Clifford Bass
 
K

Ken Sheridan

I assume you are referring to the brackets around object names. If you've
included spaces or other special characters in table or column names then
these have to be wrapped in square brackets when referenced in a query of
code. You can avoid this by not including such characters when creating the
table definitions, e.g. instead of a column named [Last Name] use LastName or
Last_Name. Also avoid using terms such as Date or Name as a column name, as
the first is the name of a built in function, the second of a property; use
something more specific such as TransactionDate or CompanyName.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top