Eu Kaique
Eu Kaique

Reputation: 13

Setting decimal in SQL Server

I have a decimal field and when I convert the string '1000,00' to decimal on my machine with SQL Server in portuguese it saves correctly 1000 but at the server, where the OS is in english, it saves 100000.

I've already set the regional settings to portuguese and the database collation to Latin1_General_CI_AS.

What I failed to do on the server?

Upvotes: 1

Views: 387

Answers (1)

Tim S.
Tim S.

Reputation: 56576

You should transfer it between the computers as a decimal (or other appropriate number type) and store is as a numeric type, if possible, not a string. If you do need to use a string at all, use the invariant culture where appropriate to convert to and from the number type, to avoid locale errors like this.

In short, the culture of the server should never come into play: you should make it fixed.

Upvotes: 1

Related Questions