cast or convert nvarchar with comma as decimal separator to decimal

  • Hello.

    My database stores the decimals in Spanish format; "," (comma) as decimal separator.

    I need to convert decimal nvarchar values (with comma as decimal separator) as a decimal or int.

    Any Case using CAST or CONVERT, For Decimal or Int gives me the following error:

    Error converting data type varchar to numeric

    Any knows how to.

    ANy knows any parameter or similar, to indicate to the Cast or Convert, that the decimal separator is a comma instead a dot.

  • [font="Verdana"]

    If possible, post some sample data with desired o/p

    Mahesh[/font]

    MH-09-AM-8694

  • i RESOLVE USING

    CAST ( REPLACE( CAST (@nDecimalWithCommaAsDecimalSeparator AS NVARCHAR),',','.') AS DECIMAL(16,4)

    SO

    SELECT (CAST ( REPLACE( CAST ('123,45' AS NVARCHAR),',','.') AS DECIMAL(16,4))

    WILL RETURN

    123.45

    Beacuse performance If any knows beest way to do, please reply..

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply