SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Format numeric values to language specific format

By thomas,

SQL Server returns numeric values always in a internal format. The conversion of numeric values
into a language specific format is usually part of the client. With this User Defined Function, you can do this
on your backend. The function expects 3 parameters: The numeric value, the requested language
and the number of decimals (will be rounded!). All parameters are described in more detail within
the function comment (header). Here're some calling examples:

SELECT dbo.fn_ConvertNumber(1500.555, 1031, 2) AS Example = 1.500,56    -- German
SELECT dbo.fn_ConvertNumber(1500.555, 2057, 2) AS Example = 1,500.56    -- Brit. English/American
SELECT dbo.fn_ConvertNumber(1500.555, 1036, 2) AS Example = 1 500,56    -- Spain, France

Please apologize my english, i'm not native speaker.

Total article views: 288 | Views in the last 30 days: 1
Related Articles

CLR Table-Valued Function Example with Full Streaming (STVF / TVF)

SQL CLR Table-Valued Functions can stream data back, but there aren't many examples of the quick and...


Metadata Functions (OBJECT_NAME for example)

What is a metadata function? According to BOL a metadata function is one that returns data about th...


Split function with store procedure

This example return a value with split function


Triggers Examples

Triggers Examples