laika222
7/10/2017 - 7:19 PM

SELECT JSON.sql

-- How to select data as JSON
SELECT TOP 5 playerID, teamID, HR from batting
FOR JSON AUTO;

-- Results:

[
{"playerID":"berrych02","teamID":"PHA","HR":0}
,{"playerID":"bettshu01","teamID":"BSN","HR":0}
,{"playerID":"birkora01","teamID":"PIT","HR":0}
,{"playerID":"bishoma01","teamID":"BOS","HR":1}
,{"playerID":"blaehge01","teamID":"SLA","HR":0}
]