Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Working on Localization - Decimal and Comma 'Decimal' Seperators

$
0
0
Note: SQL Server 2008 (Do not have the PARSE and TRY_PARSE functions available from 2012.)

Hello, I am currently working on a project to offer a localization of an existing product to other languages. This means I, unfortunately, have no say in how things were done in the past and I now have to work with what I have got.The product is a website that will need to accept numbers in the proper culture format. In the US we would write, '123456.78', however for the Spanish or French localization they may want to type '123456,78'. 

Now is where the fun starts. These values will be passed to a stored procedure in their culture specific format, which will also be the regional format of the server (both will not be supported at the same time.) The issue is that T-SQL will only cast (implicitly or explicitly) a number in the decimal format, and it does not care what regional settings are used on the server.

This leaves me with two options
1) I write a stored procedure for the 'decimal' culture that makes no modifications to the input and a duplicate stored procedure that will be used when it is a culture that uses the comma format, in which a replace would be done to change the format into the decimal format. I would then need to rewrite the website to call the appropriate stored procedure based on language.
2) Preferably, I could write a single stored procedure that does this dynamically based on the server's regional settings. If decimal, do nothing, if comma, perform replace. Ugly, but it would work. This leads me to..

Is there any way to access the database server's regional setting through T-SQL to determine the number format? I suppose I could put this value in a config table then select it, however I was hoping to keep the solution dynamic.

Any other thoughts that might help me with this?

Thanks!




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>