Re: Trim Help
From: Mike Labosh (mlabosh_at_hotmail.com)
Date: 06/17/04
- Next message: Darren Spooner: "help neeed statement"
- Previous message: Hugo Kornelis: "Re: Trigger Not Firing Properly"
- In reply to: Jeff_York: "Trim Help"
- Next in thread: Jeff_York: "Trim Help"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Jun 2004 15:56:37 -0400
> I have some junk data in a column. It is supposed to be a
> a phone number column, but someone before me had made it
> a 25 char field. I noticed I have a few entries in the
> field like this
>
> -233-3457
>
> When it should be just this:
>
> 2333457
>
> Is there a way to trim the 5th character ('-')?
You would not believe how much of this I have done. I solved it by using a
regular expression on the front end inputs to lift off all characters that
are not digits.
If you wanted to handle this cleaning inside the SQL Server you could do
something similar using sp_OACreate, spOASetProperty, spOAGetProperty,
sp_OAMethod & sp_OADestroy to manipulate a "VBScript.RegExp" COM object.
I've heard that the latter takes a performance hit ont he server, though I
haven't tried it.
One thing that you will need to consider also is numeric prefixes. Each
country has a trunk prefix which is dialed just before the area code for a
domestic call (that's a 1 in the US & Canada). For an international call, a
phone number begins with the International Prefix of the country of origin,
followed by the country code of the destination, then the area code and
number. If that stuff is important to you, you will need to check it and
verify it or not chop it off by accident or something. Here's a great
reference:
Then there's the bit about alpha characters. If you get a phone number like
"1-800-CALL-NOW" you will need to decide whether to disallow the alpha
characters, or convert them to the appropriate digits with a function.
But then what about "1-800-555-1234 ext 4700" ? You wouldn't want to
convert the "ext" into '398'.
You may be in for lots of meetings and policy discussions at work. I don't
envy your task. I've already been through it here.
Peace & happy computing,
Mike Labosh, MCSD
"SELECT * FROM Users WHERE Clue > 0"
- Next message: Darren Spooner: "help neeed statement"
- Previous message: Hugo Kornelis: "Re: Trigger Not Firing Properly"
- In reply to: Jeff_York: "Trim Help"
- Next in thread: Jeff_York: "Trim Help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|