Hi, everyone
There is a table t1 with two fields, such as,
ID NAME
1 Tokyo
2 Xian
3 America
For there are full-width and half-width strings in the values of the two fields, I can not select and get the right records. So I want to transform the two fields ID and NAME, I fail to find the function in the SQL Server 2005. Please give me some advice.
Thank you very much!try trimming all the blank spaces in the fields before running any select/ use the fields with Trim() running on them.|||thank you, wash.
The function trim only trims the blank spaces in the field.However, field values with full width or half width do not mean there are blank spces in the field.|||I have no idea what you are talking about
what are full/hald width strings?|||I think I know what he wants.
If all the data consists of single words, you can eliminate all the spaces using the REPLACE function:select replace('t o k y o ', ' ', '')
...but if some of the records contain multiple words, you are out of luck.
How did your data end up looking like this in the first place?|||How about this:
select substring (name, 1, length(name)/2)
Truncates half the string, every time. May not be what you want, but...|||Do these guys even get emails when we reply?
Half?
Ever hear of RI?|||sorry, Brett Kaiser , I did not get your email.|||thanks all.
I still failed in the problems with full width and half width. If possible, please create a table, and insert some records with full-width and half-width string, you will find it is difficult to cope with the problem.|||here's a variation of what blindman suggested that will work for your funny-spaced words as long as they are separated by two spaces between words:
select replace(replace(replace('t o k y o n i g h t s', ' ', '__ACK_ACK__'),' ',''),'__ACK_ACK__',' ')
You can replace the __ACK_ACK__ with any string you like as long as it's guaranteed never to appear in the strings you are operating on. I figure __ACK_ACK__ is pretty unlikely to appear since it's Martian. :)|||no problem will have a solution untill you define your problem statement clearly. :S
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment