简体   繁体   中英

Send json data to SQL Server 2008

I have this problem: I receive from client-side data as json in WebApi (C#) services. Data contain several data table as arrays of objects.

I need to make change in database within one transaction (according with data received from client side).

Which one is the best approach:

  1. send data to T-SQL as json (as string), and there to parse json and transform in hierarchy table as in article: Consuming JSON string in SQL ,

or

  1. parse json in WebApi services, and then send to T-SQL one by one?

I think the first method is the right one.

I succeeded to create stored procedure with parameter json string contain multiple data table. It was simple to parse the Hierarchy table created with parseJSON (see article Consuming JSON string in SQL ). According with this, I think is a good way to send multiple data table to SQL.

I want to mention: I don't have any experience with SQL Server. So maybe the question is stupid (was negative voted), but for me wasn't...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM