The below dynamic query returns the output of the numeric columns in Scientific notation.
DECLARE @Cols VARCHAR(MAX) = (SELECT STUFF((
SELECT ',' +'['+ Description + ']' FROM @PermittedColumnIDs
DECLARE @Query NVARCHAR(MAX) = 'SELECT TOP 1000 '+ @Cols +' FROM ' + (SELECT ViewName FROM
@DynamicQueryProps) + ' FOR JSON AUTO';
EXECUTE sp_executesql @Query
JSON output
Tabular output
As above mentioned, tabular view returns the AWP
value properly and JSON view returns it with the scientific notation. How to get the JSON AWP
column without Sc. notation.
Please note that
- It needs to preserve the numeric value as numeric without converting it to a string in the JSON result.
- Cannot change the format of individual columns since columns are dynamic.