2

I want to convert a result from a select into JSON format, to do this I found the following script

select rankName as name
    from tbUserHasRank 
    where userTag = 'test' 
    for json auto

however I receive the error

Incorrect syntax near 'json'.

so... what's incorrect with my syntax I wonder?

Michael Tot Korsgaard
  • 3,892
  • 11
  • 53
  • 89

2 Answers2

0

You can make your own SQL query ie

select '"name":' + '"' + rankName + '"'
from tbUserHasRank 
where userTag = 'test' 
domenicr
  • 352
  • 3
  • 14
0

I think you could create a CLR function in C# (or whatever) or you can have a look at this answer but I am not sure that special characters are correctly escaped.

Community
  • 1
  • 1
C.Champagne
  • 5,381
  • 2
  • 23
  • 35