从字面上看,这是我第一次发布,因此,如果我做错了,请原谅。
我想知道如何将其结果保存到SQL Server 2016表(临时表或烫发表)中。
谢谢。
DECLARE @json nvarchar(max)
SET @json = N'{
"response": [
{
"application": {
"info": {
"dat_id": "010.2018.00036494.001",
"development_type": "Residential - Single new dwelling",
"application_type": "DA",
"last_modified_date": "2018-12-03T11:35:24+11:00",
"description": "Residence, Garage & Colorbond Shed, Demolition of Existing Residence & Tree Removal",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-10-26T00:00:00+11:00",
)
[…..]
select * from OPENJSON(@json,'$.response')
with
(
[dat_id] varchar(200) '$.application.info.dat_id',
[development_type] varchar(200) '$.application.info.development_type',
[last_modified_date] varchar(200) '$.application.info.last_modified_date',
[description] varchar(300) '$.application.info.description',
[ref] varchar(200) '$.application.info.authority.ref',
[name] varchar(200) '$.application.info.authority.name'
)
答案 0 :(得分:0)
要从选择结果中插入表,请尝试以下方法:
DECLARE @json nvarchar(max)
SET @json = N'{
"response": [
{
"application": {
"info": {
"dat_id": "010.2018.00036494.001",
"development_type": "Residential - Single new dwelling",
"application_type": "DA",
"last_modified_date": "2018-12-03T11:35:24+11:00",
"description": "Residence, Garage & Colorbond Shed, Demolition of Existing Residence & Tree Removal",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-10-26T00:00:00+11:00",
)
[…..]
select * into results_from_query from OPENJSON(@json,'$.response')
with
(
[dat_id] varchar(200) '$.application.info.dat_id',
[development_type] varchar(200) '$.application.info.development_type',
[last_modified_date] varchar(200) '$.application.info.last_modified_date',
[description] varchar(300) '$.application.info.description',
[ref] varchar(200) '$.application.info.authority.ref',
[name] varchar(200) '$.application.info.authority.name'
)
结果应该在以下位置可用: results_from_query 表