Romesh Somani
Romesh Somani

Reputation: 373

Display integer value in minimum 2 digit before decimal in sql server

I need to display int value in minimum 2 digit before decimal in sql server. Is it possible than how pls rply?

Upvotes: 0

Views: 1314

Answers (1)

Aaron Bertrand
Aaron Bertrand

Reputation: 280383

While you really should be doing this formatting at the presentation layer, here is how to change 5 to 05:

SELECT RIGHT('00' + CONVERT(VARCHAR(12), 5), 2);

In SQL Server 2012, you will be able to leverage the new FORMAT function - much tidier and full .NET and culture support.

Upvotes: 2

Related Questions