views:

236

answers:

2

I would like to convert/cast some int or bigint to varchar (in tsql).

But I would like it to be in English regardless of database language, collation, etc. (I need to parse it back on the client side)

Basically I am looking for tsql equivalent of this C# code 1234.ToString(CultureInfo.InvariantCulture)

What should I do? Is this language independent? convert(varchar, 1234)

+1  A: 

I'm pretty sure that CONVERT(varchar, some_int) is culture invariant.

The same is not true for money or datetime

Cade Roux
I think so too. but documentation doesn't say anything about it. I thought better to ask.
john
@john I was trying to find better information on it and set up a test/demo for you at http://odata.stackexchange.com - but I think SET LANGUAGE only affects so many things even with money converts.
Cade Roux
+1  A: 

For int, a basic CAST or CONVERT won't add separators

For casting back, this is OK 1234567 but these assorted culture ones aren't: 1,234,567 or 1'234'567 or 1.234.567. And you can't generate the latter in T-SQL cleanly anyway

gbn