I need to get result of sql query in JSON format via MSSQL 2014. I have wrote this code:
SELECT bc.Id, bc.CityName, bc.ProvinceId FROM BusCity AS bc WHERE bc.Country=2 FOR JSON AUTO
But I am getting an error:
Incorrect syntax near 'JSON'.
Is this possible? How to do this?
You running 2016 or higher?
FOR JSON was introduced then.
Type
SELECT @@Version
To find out what version you're running.