How to Display Two Digits After Decimal Points in SQL Server

In SQL Server, you can use the FORMAT function or the CAST or CONVERT functions to display a specific number of digits after the decimal point. Here’s how you can do it:

Using the FORMAT Function:

The FORMAT function allows you to format values in various ways, including specifying the number of decimal places.

SELECT FORMAT(column_name, 'N2') AS formatted_number
FROM your_table;

In this example, column_name is the column you want to format, and 'N2' specifies that you want to format the number with two digits after the decimal point.

Using the CAST or CONVERT Functions:

You can also use the CAST or CONVERT functions along with the DECIMAL data type to achieve the same result.

SELECT CAST(column_name AS DECIMAL(10, 2)) AS formatted_number
FROM your_table;


SELECT CONVERT(DECIMAL(10, 2), column_name) AS formatted_number
FROM your_table;

In both examples, 10 represents the total number of digits in the number (including digits before and after the decimal point), and 2 represents the number of digits after the decimal point.

Replace column_name with the actual column name from your table and your_table with the actual table name you’re working with.

Remember to adjust the data type and precision (the first parameter in the DECIMAL type) according to your needs and the existing data type of the column.

Optimizing MS SQL Server query performance is both an art and a science. By understanding your data, crafting efficient queries, optimizing indexing, and monitoring resources, you can create a well-tuned database environment that delivers lightning-fast query results. A commitment to continuous improvement and staying abreast of the latest optimization techniques is key to maintaining top-notch performance. If you want to get updated, like the facebook page and stay connected.

Eager to become a query performance maestro? Explore more articles on our blog to deepen your database management skills. Share this guide with fellow SQL enthusiasts who are eager to take their SQL Server performance to the next level!


Remember that query performance optimization requires a balance between efficiency and maintainability. Prioritize queries that are both performant and comprehensible.

Add a Comment