如何在 SQL Server 2016 中打开 ndJSON 格式?我可以使用 JSON 格式打开,但对如何使用 ndJSON 进行操作一无所知。
SQL Server 中是否有特定的函数可以执行此操作,或者是否有其他方法?
Declare @JSON varchar(max)
SELECT @JSON = BulkColumn
FROM OPENROWSET (BULK 'C:\examplepath\filename.JSON', SINGLE_CLOB) as j
Select * FROM OPENJSON(@JSON)
With (House varchar(50),
Car varchar(4000) '$.Attributes.Car',
Door varchar(4000) '$.Attributes.Door',
Bathroom varchar(4000) '$.Attributes.Bathroom' ,
Basement varchar(4000) '$.Attributes.Basement' ,
Attic varchar(4000) '$.Attributes.Attic'
) as Dataset
Go
JSON 格式:
[
{"House":"Blue","Attributes":{"Car":"Camry","Door":"Small","Bathroom":"Medium","Basement":"Dark","Attic":"1"}},
{"House":"Red","Attributes":{"Car":"Thunderbird","Door":"Large","Bathroom":"Small","Basement":"Light","Attic":"4"}}
]
ndJSON 格式:
{"House":"Blue","Attributes":{"Car":"Camry","Door":"Small","Bathroom":"Medium","Basement":"Dark","Attic":"1"}}
{"House":"Red","Attributes":{"Car":"Thunderbird","Door":"Large","Bathroom":"Small","Basement":"Light","Attic":"4"}}