How can I get the mantissa (integer) portion of a decimal in sql

If I have decimal 123456789.456789

How can I get the 123456789 portion of it.
LVL 1
countrymeisterAsked:
Who is Participating?
 
Scott PletcherConnect With a Mentor Senior DBACommented:
If you want to truncate, so that 12.99999 became 12, you could also do:

FLOOR(decimal_column)

If you always wanted to round up, so that 12.05 became 13, you could do:

CEILING(decimal_column)
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Just cast it as an integer..
SELECT CAST(123456789.456789 as int) 

Open in new window

0
 
GeoffSuttonCommented:
or use the TQSL round:  select round(123456789.456789,0) as result
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Lawrence BarnesCommented:
Or if you don't want it to round and just want to drop it use this version ofTSQL Round:

SELECT ROUND(123456789.456789, 0, 1) as RoundWithZero
0
 
GeoffSuttonCommented:
Thanks for filling that in, Ivbarnes.  Missed it :)
0
 
Lawrence BarnesCommented:
Huzzah Scott!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.