Skip to main content

Command Palette

Search for a command to run...

SQL Server extract only the number after the decimal point

For example, in decimal number 45.90, 45

Published
1 min read
SQL Server extract only the number after the decimal point

One of my blog readers asked me "Is there a way to extract only the number after the decimal point?". For example, in decimal number 45.90, 45 is the precision and 90 is the scale value. There are several methods to get this done Let us create this dataset CREATE TABLE #Numbers (value DECIMAL(16, 3));

SOURCE http://blog.sqlauthority.com/2015/08/28/sql-server-different-methods-to-extract-scale-part-from-decimal-number/

R

Hi Soykan OZCELIK,

Just a note on precision for your reference. The precision is the number of digits in the number and scale is the number of digits after the decimal. As per the example 45.90 has precision of 4 (as there are 4 digits in 45.90) and scale of 2 (i.e., 90).

https://docs.microsoft.com/en-us/sql/t-sql/data-types/precision-scale-and-length-transact-sql?view=sql-server-ver15

Thanks, Rajanand