SQL Server ROUND Function Examples
Let’s look at some example of the ROUND function in SQL Server. Understanding SQL Server ROUND Function with examples, will help in learning the concept better.
Example 1
In this example, we are rounding off a number up to next two decimal places.
SELECT ROUND(12.3456, 2);
Output :
12.3500
Example 2 :
In this example, we are rounding off the number to the next two decimal places with the operational parameter 1 which says only to truncate the specified number (-23.456) to the given decimal places i.e., 2.
SELECT ROUND(12.3456, 2, 1);
Output :
12.3400
Example 3 :
In this example, we are using ROUND() function with a variable and getting the rounded number to -2 decimal place.
DECLARE @Parameter_Value FLOAT;
SET @Parameter_Value = -2;
SELECT ROUND(123.4567, @Parameter_Value);
Output :
100.0000
Example 4
In this example, we are rounding number to the zero number of decimal places.
SELECT ROUND(123.467, 0);
Output :
123.000
SQL Server ROUND() Function
The SQL Server ROUND() function rounds off a specified number to a decimal place.