SQL Query

smartinukl

New Member
Joined
Aug 6, 2009
Messages
1
Hi all,

Need help as I am lost. I have a field in a sql table that is supposed to be a phone number field (currently nvarchar) but it has "*" and "%" in it from the dialling process.

I need to make this field a number field using the "cast" but it will not convert due to the non number characters.

Any ideas?

Any help appreciated.

S
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
What is the database - SQL Server, Access, Oracle, etc..

Or are you pulling the fields from a database but working with them in Excel?
 
Upvote 0
Could I ask why you want this to be a number field? That's a no-no with numeric data that will not be calculated, eg phone numbers and numeric post codes.
They should be stored as text.

Denis
 
Upvote 0
I've got to agree with Denis - why do you want this field to be a number?:)

SQL does have CAST but I think that's meant to be used to change one data-type to another.

As far as I know there is no 'telephone no' datatype.

You might want to look at REPLACE but I'm still not sure if that would do what you want.

Where are you getting the data from and why do you want it to be turned into a number?

Perhaps you should look at splitting it out into international/state/regional codes etc in separate fields?:)
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top