0

according to this post: [https://dba.stackexchange.com/questions/118057/convert-string-numeric-values-with-comma-as-decimal-separator-to-numeric10-2][1]

... the following code should work:

declare @number_numeric numeric(26, 6),
        @number_str     varchar(30)    


select @number_str = '1234,12'

select @number_numeric = convert(numeric(26, 6), replace(@number_str, ',', '.'))

print 'TEST: @number_numeric = %1!', @number_numeric



go

However, this line:

select @number_numeric = convert(numeric(26, 6), replace(@number_str, ',', '.'))

throws a syntax error:

Incorrect syntax near the keyword 'replace'.

For the life of me I can't figure out what is supposed to be the problem.

Does anybody else see it?

Michael
  • 799
  • 1
  • 7
  • 16
  • it would also help to state (in description; via tags) which Sybase RDBMS product (ASE? IQ? SQLAnywhere? Advantage?) and version you're using ... they don't all share a common SQL language – markp-fuso Feb 23 '23 at 14:38

1 Answers1

0

I found it out myself.

You have to use str_replace.

The following works:

select @number_numeric = convert(numeric(26, 6), str_replace(@number_str, ',', '.'))
Michael
  • 799
  • 1
  • 7
  • 16