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

replace "ó" to "?" 2

Status
Not open for further replies.

baharehresidegan

Programmer
Apr 16, 2007
8
IR
hi
i have an excel file that i import it to sql server
this file has some records with this character: "ó"
and i cant replace it to "?" and other characters.
i must tell u that : i can do it manually but i want to do it with a Tsql Command.
tanx
 
Hi,

Won't this do the trick?

Code:
UPDATE table
SET column_name = Replace(column_name,'ó','')

Hope this helps.

Michael
 
Code:
[COLOR=blue]SELECT[/color] [COLOR=#FF00FF]REPLACE[/color](YourField,[COLOR=red]'o'[/color],[COLOR=red]'?'[/color]) [COLOR=blue]FROM[/color] YourTable

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Sorry, ignore previous post.

Below should do what you want.
Code:
UPDATE table
SET column_name = Replace(column_name,'ó','?')
where column_name = 'ó'
Hope this helps.

Michael
 
Better be:
Code:
where column_name LIKE '%ó%'
:)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Dear Friends
i know this way . it is not useful for my problem .
you can test this command and see that command doesn't solve my problem
.
 
baharehresidegan,

We going to need more information then, can you post some sample data?

Michael
 
sample for u :
For example :
my table is "Table2"
"Table2" has One field named "a" (Type = nvarchar(50))
for example these records are in "table2"

ó456
fgró456
refg45ó567

I cant use "replace" command for change "ó" to "?"
this command doesn't solve my problem

 
Dear ca8msm
If i knew my problem , i solve it.
but i dont konw
i used "replace" command in my programs many times
but i dont underestand why it not useful for me to replace "ó" to "?
 
I'm confused.

____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done
 
I'm confused because there is no valid reasoning behind not being able to use the built in replace function. At least you haven't given one.

The example you have given only pushes one reply to your thread. That being use the Replace() function.

Unless there is some underlying reasoning behind why this function will not work for you I'm not sure there is a more efficient or stable method to do this task.

Is there one?

____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done
 
baharehresidegan,
Maybe you try to replace wrong char. Go to record where you have such char find the position and issue this:
Code:
SELECT ASCII(SUBSTRING(YourField,position of that char,1))
       FROM YourTable
       WHERE PK = (primary key value of the record where that char exists)
That could give you correct ASCII value of that char. The you could use:
Code:
UPDATE YourTable
       SET YourField = REPLACE(YourField,CHAR(ASCII code you got before), '?')
(for me ASCII value of that char is 111) but you should check it on your side.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
I'm stumped. If it's once off why not do the find replace in Excel maybe.

Michael
 
Because Excel is a horribly unstable environment. You should never reply on it other than viewing purposes. It is a desktop application meant for the users.

That is of course unless you want to have your business fall to its knees in the event a simple office update decides your functions need to be slightly different due to security risks and all thus breaking everything you are doing.

Along with creating a maintenance situation that is never ending. Job security right? ;-)

____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done
 
Very true onpnt...what can I say, I'm probably just as unstable as Excel! :)

I find the above very weird. I imported an excel sheet containing ó in SQL 2000 and used the replace command no problem.

Michael
 
Dear ca8msm
If i knew my problem , i solve it.
but i dont konw
i used "replace" command in my programs many times
but i dont underestand why it not useful for me to replace "ó" to "?"
Your replies don't make any sense. The Replace command works perfectly, will work for you in this case and a code solution using this Replace command has been given to you (by both micanguk and bborissov). You are are the one who is saying you can't use it yet you don't give a reason why you can't use it. This is why everyone seems confused at your posts.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top