Formatting Phone Numbers In SQL

May 28, 2008

Here's my problem: I have to clean up a SQL Server 2005 database with a large number of phone number records (several hundred thousand). The records are of varchar datatype and contain phone numbers in every format imaginable. In fact, many records have written notes regarding the phone numbers after the numbers themselves. What I need to do is format all of the phone numbers to this format:

###-###-####-

Basically I'm figuring I need to do the following:
1. Strip all non-numeric characters from the record
2. Remove the 1 from any records that have a leading 1 (in many cases the records contain stuff like 1-888-555-1234)
3. Remove any digits following the first 10 digits (they don't want to keep any extensions - the formatting is more important)
4. Add dashes after the first three digits, after the second three and at the end of the phone number

This seems like a rather complex problem to me, and honestly I don't even know where to begin. I can accomplish this rather easily in javascript or C#, but writing SQL to solve this is beyond me. I'd really appreciate any help you guys can provide. Thanks alot!

View 14 Replies


ADVERTISEMENT

Formatting Phone Numbers

Jul 17, 2000

What is the simplest way to format the 10 digit numeric string that represents a phone number, so that the result appearing on a web page looks like (xxx) xxx-xxxx. Should this take place in the database or out at the web server or where?

View 1 Replies View Related

Formatting Numbers In A Mixed Column (numbers In Some Cells Strings In Other Cells) In Excel As Numbers

Feb 1, 2007

I have a report with a column which contains either a string such as "N/A" or a number such as 12. A user exports the report to Excel. In Excel the numbers are formatted as text.

I already tried to set the value as CDbl which returns error for the cells containing a string.

The requirement is to export the column to Excel with the numbers formatted as numbers and the strings such as "N/A' in the same column as string.

Any suggestions?



View 1 Replies View Related

Formatting For Phone?

Aug 7, 2007

In my report I am combing 2 fields as

=Fields!PROPERTY.Value & " - " & Fields!PHONE.Value


this results in PropertyName - 5555551212

How would I add in formatting for phone so my resulting display is (555) 555-1212?

View 5 Replies View Related

Phone Number Formatting

Feb 12, 2013

I have a table filled with phone numbers entered in every different way possible

(5551212, 1115551212, 111-555-1212, 111 555 1212, 111-555-1212 ex 1234, 5551212 x1234)

And I would like to pull them from the table using sql 2008 and have the formatting look like this:

(111)555-1212 x1234.

How can I make this happen? Where numbers are missing, I would prefer to leave the area blank, ie 5551212 becomes 555-1212, and 1115551212 becomes (111)555-1212, extension numbers only where they are currently included.

View 14 Replies View Related

Phone Number Formatting

Apr 26, 2007



If I have a string of 10 numbers (with no other characters), what is the best way to format them into a standard phone format: xxx-xxx-xxxx?



I tried numerous variations in the format code and edit expression areas, but no luck.

View 12 Replies View Related

RE:PHONE NUMBERS UPDATE

Aug 14, 2001

I am trying to update a bunch of phone numbers in a sql 6.5 db.
The phone numbers are in the following formate.
(aaa)-xxx-cccc
I need to update xxx to yyy. Has anyone done this before.
Please help.


Thanks in advance

Ken

View 3 Replies View Related

Storing Phone Numbers

Jul 20, 2005

Hi,In SQL Server 2000, if I have to create a table to store a very largenumber of 10 digit telephone numbers, would I be better off to have abigint field or just use a varchar field? If I do a lot of queryingbased on the telephone numbers, would it be faster if I use bigint?Are there any other tricky points that I should know when using bigintfields? I need to be able to accesss this field from VB6 and VB.NET.Thanks,--TP

View 3 Replies View Related

Remove Formatting From Phone Number Column

Jul 9, 2000

I have a column of phone numbers that have formatting such as (xxx)xxx-xxxx,
or xxx.xxx.xxxx or xxx.xxx-xxxx; however, not all phone numbers are formatted in this fashion. I need to remove all characters and only leave behind numeric digits to look like xxxxxxxxxx. I have tried select replace(colname,'-','') from table. This does the trick but does not actually change the values in the column. Any help in accomplishing this would be helpful. Thanks in advance.

Paul

View 1 Replies View Related

Phone Number Formatting - Standardize Information

Sep 23, 2013

SQL query: I am importing data from one source to another. The phone number has 3 variations and I want to standardize the information. I need to remove the "+1" or "1" from the leading characters of the phone number.

example:
13035554444
+13035554444

View 4 Replies View Related

Create Table For Phone Number Formatting?

Jul 15, 2014

I am trying to get my SQL create table to work for my phone number formatting and it is not. When I create the below code, the default is set to 3 numbers only.

CREATE SET TABLE dl_qpt_cqe.contacts, NO FALLBACK ,NO BEFORE JOURNAL,NO AFTER JOURNAL

(contact_id integer not null ,contact varchar(50) , jobtitle varchar(50), dept varchar(50), phone integer format '999-999-9999', phone_ext varchar(10), email varchar(50), constraint pk primary key (contact_id));

Is there some other way I need to format the phone portion so the default is 999-999-9999?

View 1 Replies View Related

Fixing Phone Numbers To Correct Format

Aug 14, 2014

I am trying to find all the records in our database that have the incorrect phone number format and fix them to the correct format.

CREATE TABLE MDR (
SiteName nvarchar(255),
BusinessEmailAddress nvarchar(255),
FirstName nvarchar(255),
LastName nvarchar(255),
JobTitle nvarchar(255),
PersonBusinessPhoneNumber nvarchar(255),
SiteBusinessPhoneNumber nvarchar(255))

[code]....

View 1 Replies View Related

Stripping Input Mask From Phone Numbers

Mar 28, 2006

Hello, I have this Access 2K query that I need to re-create in MS SQLServer 2000, so I'm using the Query Analyzer to test it.One of the Access fields stores the home phone number. In the Accessquery, if the phone number is null, it fills it up with zeroes"000000000." If the phone has an input mask, it only gets the 9 numbers(area code included) and if the phone number's good (all numbers) thenit leaves it alone. That Access query is using immediate ifs toaccomplish that task.Does anyone have any idea how to copy this behavior into SQL Server2000? I've using the CASE statement but so far my code is not correct.I get stuck in the input mask. This is the Access code:HomePhone:IIf(IsNull([HomePhone]),"0000000000",IIf(Left([HomePhone],1)="(",Right(Left([Homephone],4),3)& Right(Left([Homephone],9),3) & Right([HomePhone],4),[HomePhone]))Thanks for all your help.JR.

View 2 Replies View Related

SQL Or Visual Web Developer 2005 To Arrange Phone Number Formatting?

Jul 31, 2006

i am trying to build a database that contains a coloumn of phone number but i reallly dont know where and how i will be able to give a specific format for phone numbers.. or anything else any common type of information that may have a format..



Will i use Visual Web Developer or SQL Server Management or whatever else to arrange my phone number coloumn?

View 5 Replies View Related

CASE Function Home Phone Work Phone Cell Phone

May 8, 2008



Hi,

I'm trying to create a case function for home phone ,work phone and cell phone. The thing is some of the home phone numbers either null, zero or less than 10 digits then i'd like to get either cell phone or work phone if they are not null, zero or less than 10 digits.

I'd appreciate it if you could help me on this?

Thanks in advance.

View 19 Replies View Related

Store Phone Numbers/Zip Codes As Char(length) Or Numeric Datatypes?

Dec 18, 2003

I'm wondering which way is the best way to store your numeric values.
It probably doesnt matter, b/c you can always convert back and forth...but i'm just wondering what the best practice is i guess...


thx

View 1 Replies View Related

Formatting Numbers

Jan 18, 2005

I am using a MS Access ADP connected to SQL Server Data

In a view I have the following formula:

dbo.tblQuoteItem.Cost + dbo.tblQuoteItem.Markup * dbo.tblQuoteItem.Cost * .01

this calculates cost + markup

I cannot get it to format in Currency

Ex:

Cost is $1.75
Markup is 2.00 (2%)
Total shows - 1.785000

I want $1.78

Also - I am using this formula to calculate the Quoted price for the Qty Entered

dbo.tblQuoteItem.Qty * dbo.tblQuoteItem.Cost + dbo.tblQuoteItem.Markup * dbo.tblQuoteItem.Cost * .01

Using a Qty of 2 for above, I get 3.535000

I want $3.53


Any help is appreciated - AB

View 2 Replies View Related

Formatting Numbers

May 20, 2008

I know this sounds like a basic question, but how do u add a leading 0 to a number, ie, 43 becomes 043

Thanks

View 6 Replies View Related

Formatting Numbers

May 21, 2008

On the layout page of Reporting Services I have a table. One of the cells contains the following expression:




=Sum(Fields!S2Agresso.Value)



S2Agresso is a decimal type. It contains values such as 0.00, 3.30 etc.

I need it to display it in the following fomat - 00.00
i.e
0.00 becomes 00.00
0.30 becomes 00.30
3.13 becomes 03.13
10.20 remains as 10.20

etc.

Can anyone help?





View 8 Replies View Related

Formatting Numbers In An SQL Statement

Aug 23, 2005

Hi,I have a table that has an ID field which is automatically incremented as each new record is added, so if I do a SELECT * FROM Table1 I get:ID, Name1, Billy2, Bob3, TonyYou get the idea.  What I want to do is format the number differently when it's returned from an SQL statement so I get:ID, Name0001, Billy0002, Bob0003, TonySo I need something like SELECT FORMATNUMBER(ID, 4), Name FROM Table1 - Does anything like this exist?Little 'un.

View 2 Replies View Related

Formatting Numbers With Commas In TSQL

Jul 20, 2005

Once I've converted my floats to chars using STR, is there an easy wayto put commas in separating the thousands.i.e. convert53000000.12to53,000,000.12I'm thinking I'll have to do it with a user defined function and thevarious string functions myself but was wondering if anyone had aneasier way?CheersDave

View 6 Replies View Related

Formatting Currency Numbers From Analaysis Services

Feb 8, 2007

Hi,

I'm using Reporting Services in conjunction with Analysis Services.

The problem I'm having is formatting numbers to be dollar amounts. I know how to set this in Reporting Services and when a data source was regular SQL, then everything was just fine. However, when I switch to Analysis Services the number would just stay the same.
i.e. "60.2" instead of "$60.20". The only thing I can think of is if Analysis Services is returning the number as a string for some reason, and RS won't format strings for currency.

Any thoughts? Thanks!

View 4 Replies View Related

Conditional Formatting Expression - Evaluate First 3 Characters Of String As Numbers

Mar 2, 2012

I'm trying to put conditional formatting on a field, that behaves as follows:

The data in the field is varchar, and sample data is either:

NULL
3.0 :0
11.7 :1 (these are ratios of a sort)

I want to evaluate the first 3 characters of the string as numbers.

Example:
Mid(fieldvalue,1,3) = "3.0" or "11."

Any data that is greater than 1.99, I want to make the background dark red, anything else including nulls, zebra formatting. I have the following expression built so far and it appears to work, except when the value is null. If the value is null, it leaves the background color white.

This is the warning: [rsRuntimeErrorInExpression] The BackgroundColor expression for the text box "Asthma" contains an error: Input string was not in a correct format.

=iif(
isnothing(Fields!Asthma.Value)
,(IIf(RowNumber(Nothing) Mod 2 = 0,"#b8cce4","#dbe5f1"))
,(iif(mid(Fields!Asthma.Value,1,3)>1.99
,"DarkRed"
,IIf(RowNumber(Nothing) Mod 2 = 0,"#b8cce4","#dbe5f1"))))

My logic is, if the field is null, zebra format, if mid of the value is > 1.99, dark red, everything else zebra formatting. As I said, this seems to work except for nulls.

View 2 Replies View Related

Query Analyzer Shows Negative Numbers As Positive Numbers

Jul 20, 2005

Why does M$ Query Analyzer display all numbers as positive, no matterwhether they are truly positive or negative ?I am having to cast each column to varchar to find out if there areany negative numbers being hidden from me :(I tried checking Tools/Options/Connections/Use Regional Settings bothon and off, stopping and restarting M$ Query Analyer in betwixt, butno improvement.Am I missing some other option somewhere ?

View 7 Replies View Related

I Need To Update A Table With Random Numbers Or Sequential Numbers

Mar 11, 2008



I have a table with a column ID of ContentID. The ID in that column is all NULLs. I need a way to change those nulls to a number. It does not matter what type of number it is as long as they are different. Can someone point me somewhere with a piece of T-SQL that I could use to do that. There are over 24000 rows so cursor change will not be very efficient.

Thanks for any help

View 6 Replies View Related

Generate List Of All Numbers (numbers Not In Use)

Feb 21, 2007

I have an 'ID' column. I'm up to about ID number 40000, but not all are in use, so ID 4354 might not be in any row. I want a list of all numbers which aren't in use. I want to write something like this:

select [numbers from 0 to 40000] where <number> not in (select distinct id from mytable)


but don't know how. Any clues?

View 1 Replies View Related

Dataflow To Excel - Convert Numbers Stored As Text To Numbers Excel Cell Error

Mar 27, 2007

I'm trying to write data to excel from an ssis component to a excel destination.

Even thought I'm writing numerics, every cell gets this error with a green tag:

Convert numbers stored as text to numbers

Excel Cells were all pre-formated to accounting 2 decimal, and if i manually type the exact data Im sending it formats just fine.

I'm hearing this a common problem -

On another project I was able to find a workaround for the web based version of excel, by writing this to the top of the file:

<style>.text { mso-number-format:@; } </style>

is there anything I can pre-set in excel (cells are already formated) or write to my file so that numerics are seen as numerics and not text.

Maybe some setting in my write drivers - using sql servers excel destination.


So close.. Thanks for any help or information.

View 1 Replies View Related

Phone Format

Jun 22, 2006

SQL Database with column cell-phone formatted 1234567890. I want to display it (123) 456-7890. I use the following to display it as 1234567890:
<%# Directory.FieldValue("cell_phone", Container) %>
I tried the following code but get a formatting error:
<%# Double.Parse(Directory.FieldValue("cell_phone", Container)).ToString("(###) ###-####") %>
What stupid error am I making?

View 5 Replies View Related

Phone Number

Aug 24, 2001

I have 2 tables with different phone field format. Looks like below:
TableA
field name area
record 111
and field name phone
record 2223333

TableB
field name Phone
record (111) 222-3333 *
*with a space between (111) and 222

I want to transfer tableA (area+phone) field to tableB phone field and transfer tableB phone field to tableA area field and phone field.

Anybody can help me to finish it? Thank you very much!!!

View 1 Replies View Related

Phone # Question

Aug 9, 2005

I assume a SS# or Phone# should be either a varchar or char field. Butis it a good idea to store a phone# or SS# w/ seperator characters orwithout them?Phone# "(123)-456-7890" or "1234567890"SS# "123-45-6789" or "123456789"I'm not sure which is better. Any opinions? Also has anyone had asituation where a phone# could have an extension? How was it handled?Seperate field or just one?Any input appreciated. Thanks.

View 6 Replies View Related

Sms To Mobile Phone

Apr 26, 2007

hai,



how can i send sms through web page(without using web service) to mobile phone using SQL server 2005

View 2 Replies View Related

Format Phone Number

Jul 21, 2006

Hi Everyone,
   I have a phone number coming from the database coming in the format of 2132563111. How can I do this in sql query213-563-3111
Please let me know if there is any function that does it.
Thanks.

View 1 Replies View Related

Trimming Phone Number

Apr 10, 2008

Hi all,
 
i have a table in SQL with +- 5000 phone numbers in various styles
e.g.
 0515 - 578989           
033 2981861             
+31 (0)30 602 44 44     
03.28.68.63.18
03/658.85.80
 
I want this to convert to international format like this
003237778899
0031306024444
 
Do i have to write 10 replace after each other or is there an easier way to format the phone numbers?
 
 
Thx in advance!!

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved