Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Substring

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2014-08-15 : 10:52:14
Hi All,

I have one column phone float now I have to remove 1144 from starting

I can not run substring query please suggest

9740084226
9740084227
11449964743899

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-15 : 14:29:59
Why is a phone number stored as a float?


select cast(cast(11449964743899 as float) as bigint) % 11440000000000
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-08-18 : 05:22:37
quote:
Originally posted by gbritton

Why is a phone number stored as a float?


select cast(cast(11449964743899 as float) as bigint) % 11440000000000



This is enough


select cast(cast(11449964743899 as float) as bigint) % 10000000000

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-08-18 : 05:23:47
quote:
Originally posted by sanjay5219

Hi All,

I have one column phone float now I have to remove 1144 from starting

I can not run substring query please suggest

9740084226
9740084227
11449964743899


You should use VARCHAR datatype to store it and use right function

select right(phone,10) from table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -