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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with ' in where clause

Status
Not open for further replies.

snowneil

Programmer
Mar 22, 2006
40
GB
Hi,

What do you do if you want to search for someones surname if it is something like O'brian etc.

For instance the sql where clause is:

WHERE surname = 'o'brian'

would be incorrect.

It returns an error of Incorrect syntax near 'brian' because of the '.

I use
Code:
surname = surname.replace(/\'/g,"''");
in asp javascript to save the surname correctly to the database, but the same regexp won't work for an sql statement's where clause.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top