January 22, 2014 at 2:47 am
Hi All,
I have a varchar field with below data
DATA:
€ 100.00
NULL
I am trying to remove the € using replace function and trying to convert the varchar field to a decimal /float data type.
How ever I get the error converting varchar to numeric/float /decimal and so on.
Any help on this?
Thanks
January 22, 2014 at 3:37 am
This works fine:
DECLARE @test1 VARCHAR(10) = '€ 100.00';
DECLARE @test2 NUMERIC(10,2);
SET @test1 = RTRIM(LTRIM(REPLACE(@test1,'€','')));
SET @test2 = CONVERT(NUMERIC(10,2),@test1);
SELECT @test2;
If it doesn't work, check the regional settings.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 22, 2014 at 6:49 am
It works fine for me too and I'm in the United States. I'm wondering, what's the NULL below the value?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply