数据库将具有链接到每个 SQL 级别的身份。还想将所有三个表的数据合并到一个主表 Table_master 中,该表将具有基于内部元素记录 id 2 的最终数据数。
预计使用外键将数据更新到 SQL Server 2016 表结构的表中以及如何将相同的数据再次导出到共享网络驱动器文件夹中的 Json 中。
复制代码:
IF OBJECT_ID('dbo.Table1') IS NULL
CREATE TABLE dbo.Table1
(
Name VARCHAR(100), Location VARCHAR(100), Region VARCHAR(100)
)
DECLARE @MYJSON VARCHAR(1000)
SET @MYJSON = '
{
"Name":"ABC",
"Location":"East US",
"Region":"West US",
"Element":
[
{
"Name":"IE1",
"Description":"IE1 Description",
"Type":"Small",
"InnerElement":
[
{ "Key":"Name", "Value":"IME1"},
{"Key":"AnotherProperty","Value":"Value1"}
]
},
{
"Name":"IE2",
"Description":"IE2 Description",
"Type":"Medium",
"InnerElement":
[
{"Key":"Name","Value":"IME2"},
{"Key":"Address","Value":"Xyz"},
{"Key":"Type","Value":"Simple"},
{"Key":"LastProperty","Value":"ValueX"}
]
}
]}
'
SELECT
JSON_VALUE(@MYJSON,'$.Name') As Name,
JSON_VALUE(@MYJSON,'$.Location') As Location,
JSON_VALUE(@MYJSON,'$.Region') As Region