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

Trouble with Select Statement For Records with Apostrophe

Status
Not open for further replies.

bmann

Programmer
Oct 8, 2002
128
US
Hello. I am having trouble with ths SQL code in sql analyzer. I am trying to change the lastname O'NEIL to
ONEIL.


Update cal.dbo.name
set last = Replace(last , "'", "")
where last LIKE 'O''NEIL%'


This is the error I get.

Server: Msg 1038, Level 15, State 3, Line 2
Cannot use empty object or column names. Use a single space if necessary.
 

i dont understand what you are doing but you are missing qutoes in your replace statement
Code:
set last = Replace(last ,"'", "''")

-DNG
 
oh ok...i was wrong..so you want to totally replace the single quote...

-DNG
 
Hello DOTNETGNAT. Let me Explain.

Field Data

Last O'NEIL


I want to change Data to take the apostrophe from name:

Field Data

Last ONEIL


 
UPDATE cal.dbo.name
SET last = REPLACE(last , '''', ' ')
WHERE last LIKE 'O''NEIL%'


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top