[英]Unable to import json array to sql table in azure data factory
I have a JSON array similar to this.我有一个与此类似的 JSON 阵列。
{
"first":
{
"heading":{
"row":[
{
"@captain" :"dhoni",
"@runs":"50"
},
{
"@captain" :"Kohli",
"@runs":"150"
}
]
}
}
}
But I am not sure how to add a sql script to import this JSON to my sql table.但我不确定如何添加 sql 脚本来将此 JSON 导入我的 sql 表。 Can anyone help on this
任何人都可以帮忙吗
You can insert the rows extracted from the json returned by your API call with the help of for each activity
and script
activity.您可以在
for each activity
和script
活动的帮助下插入从 API 调用返回的 json 中提取的行。
@pipeline().parameters.my_json['first']['heading']['row']
insert into dbo.player(captain,runs) values ('@{item()['@captain']}','@{item()['@runs']}')
Another approach using stored procedure:使用存储过程的另一种方法:
create or alter procedure insert_player @json varchar(max)
as
begin
insert into player SELECT * FROM OPENJSON(@json,'$.first.heading.row') with ([@captain] varchar(30),[@runs] varchar(30))
end
@string(pipeline().parameters.my_json)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.