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

How do I send a hyphen in a SQL statement?

Status
Not open for further replies.

SirPaladin

Programmer
Jul 9, 1999
32
0
0
US
I need to use SQL to perform a lookup, but I don't know how to format the search string if it includes a hyphen. For example, looking up the name "O'Neill" currently produces an error due to the hyphen. What's the work-around?
 
I assume you mean the apostrophe "'" (a hyphen is a "-").

For each apostrophe that is part of the quoted data, simply double it. Thus, your SQL statement might be:

Code:
  SELECT * FROM MyTable WHERE LastName = 'O''Neill';
Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top