Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use apostrophe in query

Status
Not open for further replies.

lb1

Technical User
Apr 19, 2002
109
US
I have an SQL statement where my search criteria could include an apostrophe. The parameter is pased to the query.
What could I do to correct the following query to accept an apostrophe in the test parameter?

For example, il the search criteria is "four o'clock" how can I replace the ' ?
Thanks in advance.
louis
 
Use two ' in your query

Code:
select * from t where c = 'four o''clock'

Best is to do a replace on the search value, e.g. using VB-script

Code:
q = "select * from t where c = '" & replace(search,"'","''") & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top