ascendix
asked on
SQL Server Polish Formatted Strings
I hvae alot of decimal string formatted in the polish locale and SQL server is erroring everytimwe I try to cast as decimal.
here si an example 1 400,50
Any help would be appreciated.
here si an example 1 400,50
Any help would be appreciated.
ASKER
the problem with this is that if I have a US formatted number is going to mess it up
like 1,000.0
like 1,000.0
Remove the comma at all as below:
set @strval = '1 400,50'
set @decval = convert(decimal(10,2),Repl ace(Replac e(@strval, ',',''),' ',''))
select @strval as OldVal, @decval as DecVal
set @strval = '1 400,50'
set @decval = convert(decimal(10,2),Repl
select @strval as OldVal, @decval as DecVal
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Ah, the original message didn't indicate you had BOTH US and Polish. Then, as indicated, just switch on by examining the format. If the value has a space, then treat it as Polish and convert it. If not, treat it as US and do no Replace(); just convert it to decimal.
ASKER
Thanks a bunch this worked great
declare @strval varchar(50), @decval decimal(10,2)
set @strval = '1 400,50'
set @decval = convert(decimal(10,2),Repl
select @strval as OldVal, @decval as DecVal