Tags
Interesting Interview Questions, Interview Qs.SQL SERVER Questions, Interview questions, Interview Questions on SQL, InterviewQuestions, InterviewQuestions for SQL, Methods to find distinct values with out using distinct keywords, puzzle sql developer, Queries for SQL Interview, SELECT Puzzle, SQL, SQL 2012, SQL 2014, SQL 2014 Interview Questions, SQL Interview Questions, SQL Joins, SQL Queries, SQL Quiz, SQL Server Database, SQL SERVER Interview questions, SQL SERVER | How to get Decimal and Integer Part from Decimal Value, SQL Skills, SQL Tricky question, sql/database interview for puzzle sql developer, SQLSERVER, T SQL Puzzles, Tricky Questions, TSQL, TSQL Interview questions, TSQL Queries
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.