cancel
Showing results for 
Search instead for 
Did you mean: 

How to make FOR JSON respect numeric() scale?

Chris26
Participant
1,086

If I run the following SQL from Interactive-SQL on version 16.0.0.2798

begin
  declare test numeric(4,2);
  set test = 40.73;

  select test as testNumeric,
         string(test) as testString
     for json raw;
end

The result I get is:

forjson(256,'testNumeric',jsontab."1",'testString',jsontab."2")
[{"testNumeric":40.729999999999994,"testString":"40.73"}]

How can I get "testNumeric" to be represented as 40.73 in the output?

Accepted Solutions (0)

Answers (0)