Tags

, , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


SQL SERVER | How to get Decimal and Integer Part from DecimalValue

Recently there was a scenario where we need to extract the decimal and the integer part for the decimal value. We have used below method.


--

/*

Easiest method to get decimal part and Integer part from Decimal Value

*/

DECLARE @DecimalValue AS NUMERIC(10,2) = 23.66
SELECT  @DecimalValue DecimalValue
       ,@DecimalValue - @DecimalValue % 1 DecimalPart
       ,@DecimalValue % 1 DecimalPart

--

Keep learning !, Please add a comment if you have a better idea in the mind.

We all need to learn.

http://MSBISkills.com