创建存储过程:
CREATE PROCEDURE InsertOrders(@orders nvarchar(max)) AS BEGIN insert into Orders(Number, Date, Customer, Quantity) select Number, Date, Customer, Quantity FROM OPENJSON (@orders) WITH ( Number varchar(200), Date datetime, Customer varchar(200), Quantity int ) END
字段和表结构对应。
然后执行存储过程:
EXEC [InsertOrders] '[{"SOURCE":"Tmp"},{"SOURCE":"Tmp"}]'
成功插入数据库。