Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
Phone number formatting
Phone number formatting
Rate Topic
Display Mode
Topic Options
Author
Message
Sirish-791018
Sirish-791018
Posted Tuesday, September 08, 2009 6:17 AM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, January 23, 2013 6:28 AM
Points: 40,
Visits: 66
Hello,
Please let me know how to retain the + symbol and truncate the decimals
from the following. i tried with round and celing but of no use.
The datatype is varchar.
Example 1: +9966557785.0000000000000000
Example 2 : +9999665545.0000000000000000
Regards,
Sirish
Post #784175
Dave Ballantyne
Dave Ballantyne
Posted Tuesday, September 08, 2009 6:22 AM
SSCommitted
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 3:05 AM
Points: 1,943,
Visits: 8,229
Possibly the easiest way would be
select convert(bigint,+9966557785.0000000000000000)
Depends on what you want to do with the number after this really though.
Clear Sky SQL
My Blog
Kent user group
Post #784178
Sirish-791018
Sirish-791018
Posted Tuesday, September 08, 2009 6:46 AM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, January 23, 2013 6:28 AM
Points: 40,
Visits: 66
SELECT SUBSTRING(phonenumber,1,charindex('.',phoneNumber)-1) from table
Post #784191
Jack Corbett
Jack Corbett
Posted Tuesday, September 08, 2009 1:48 PM
SSChampion
Group: General Forum Members
Last Login: Today @ 8:25 AM
Points: 10,613,
Visits: 11,955
Sirish likely has the best answer for fixing currently incorrect data, the real issue is to fix the data entry application.
Another option in SQL Server if the # of characters to the left of the decimal are consistent is this:
SELECT Left('+9999665545.0000000000000000', 11)
Jack Corbett
Applications Developer
Don't let the good be the enemy of the best. --
Paul Fleming
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #784550
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.