Perhaps one of the lesser-known features of the FORMAT()
function in SQL Server is one that enables you to apply conditional formatting to a number.
It’s more of a .NET feature than it is a SQL Server (or T-SQL) feature, but SQL Server/T-SQL supports it all the same, allowing you to take full advantage of the ability to apply conditional formatting to numbers.
It all comes down to the format string you pass to the FORMAT()
function.
You can pass a format string that specifies how the number should be formatted, depending on whether it’s positive, negative, or zero.