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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
All Courses

From novice to tech pro — start learning today.