Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
ID Numbera mobile
1 2021/23958 9.98911e+007
2 2021/24584 9.60002e+007
3 2023/29525 6.906e+007
4 2023/29538 9.9044e+007


above data in table and i want to get mobile column as number because its phone number. how to write query to get data as phone number .please help me to get the correct result.

What I have tried:

i tried using float but its not showing correct . its show like this

Select convert(float, (mobile)) as mobile from [TestDB].[dbo].[TESTA]

mobile
99891100
96000200
69060000
99044000


but above value not correct

correct values
99891057
96000179
99044040
69060001
Posted
Updated 25-Apr-23 21:56pm

1 solution

Despite the name, a phone number is not actually a number. You would never perform mathematical operations on it - for example, adding two phone numbers together makes no sense.

Phone numbers need to be stored and processed as strings.

And if you've actually store the value as 9.98911e+007, then the data is corrupt and cannot be recovered. You have only stored the first six digits of the "number", and you have rounded the "number", so digits seven and eight are lost, and digit six is almost always going to be wrong.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900