Json_Value get special character

hasan golshahri 21 Reputation points
2021-03-22T11:05:08.24+00:00

Hi
declare @myfeature varchar(max) = '{"fieldterminator":",","rowterminator":"\n"}',@FeaturesForScript varchar(max)=''
set @FeaturesForScript += isnull(', FIELDTERMINATOR = ''' + JSON_VALUE(@myfeature,'$.fieldterminator') + '''','')
set @FeaturesForScript += ISNULL(',ROWTERMINATOR = ''' + JSON_VALUE(@myfeature,'$.rowterminator') + '''','')

select @FeaturesForScript

when I use "\n" the Json_Value can not get that character and this is empty
result show for me
, FIELDTERMINATOR = ',',ROWTERMINATOR = ' '
Is this Ok?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,817 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.7K Reputation points
    2021-03-22T11:20:55.853+00:00

    Try selecting from menu: Query, Results To, Results to Text, then execute the query. You will see the new-line corresponding to “\n”, but which is not visible in case of grid.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful