Answer the question
In order to leave comments, you need to log in
How to move tuples to another table?
Hello!
I parsed the data, and wrote the data to a json file, after which I transferred this data to a table:
select Name, CapitalCity, LargestCity, Admission, Population from OpenJson('
[
{
"name": "Alabama",
"capitalCity": "Montgomery",
"largestCity": "Birmingham",
"admission": "Dec 14, 1819",
"population": "4,903,185"
}, ...
')
with (
Name nvarchar(20) '$.name',
CapitalCity nvarchar(30) '$.capitalCity',
LargestCity nvarchar(20) '$.largestCity',
Admission nvarchar(20) '$.admission',
Population nvarchar(20) '$.population'
)
create table State(
ID int not null,
Name nvarchar(20) not null,
CapitalCity nvarchar(30) not null,
LargestCity nvarchar(30) null,
Admission nvarchar(20) null,
Population nvarchar(20) not null,
primary key(ID),
)
Answer the question
In order to leave comments, you need to log in
INSERT INTO MyTABLE (Name, CapitalCity, LargestCity, Admission, Population)
select Name, CapitalCity, LargestCity, Admission, Population from OpenJson('
[
{
"name": "Alabama",
"capitalCity": "Montgomery",
"largestCity": "Birmingham",
"admission": "Dec 14, 1819",
"population": "4,903,185"
}, ...
')
with (
Name nvarchar(20) '$.name',
CapitalCity nvarchar(30) '$.capitalCity',
LargestCity nvarchar(20) '$.largestCity',
Admission nvarchar(20) '$.admission',
Population nvarchar(20) '$.population'
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question