open-json

openjson : SELECT star

最后都变了- 提交于 2021-01-29 08:48:49
问题 I have a table in a json file (C:\db.json): [{"_id":"81743561","_record_number":"1","_form_id":"618213","_user_id":"218754",...}, {"_id":"81782299","_record_number":"2","_form_id":"618213","_user_id":"218754",...}, {"_id":"81784481","_record_number":"3","_form_id":"618213","_user_id":"218754",...}] It has about 60 "columns". I have a 100 "tables" like this to import into SQL Server, each with its own schema. I found it could be done this way: Declare @JSON varchar(max) SELECT @JSON=BulkColumn

A concatenation OPENJSON in a SQL Server 2016 stored procedure

做~自己de王妃 提交于 2019-12-11 06:04:53
问题 I need to combine all of the authors for a particular UID. The basic fields are working from the code at another post. DECLARE @json NVARCHAR(MAX) SET @json = '{ "header": { "type": "esummary", "version": "0.3" }, "result": { "uids": [ "17784783", "19505939", "30166592" ], "17784783": { "uid": "17784783", "pubdate": "2007 Aug", "epubdate": "2007 Jul 20", "source": "PLoS Comput Biol", "sortpubdate": "2007/08/01 00:00", "authors": [ { "name": "Yu Y", "authtype": "Author", "clusterid": "" }, {

SQL Server OPENJSON read nested json

ⅰ亾dé卋堺 提交于 2019-11-28 03:29:31
I have some json that I would like to parse in SQL Server 2016. There is a hierarchy structure of Projects->Structures->Properties. I would like to write a query that parses the whole hierarchy but I don't want to specify any elements by index number ie I don't want to do anything like this: openjson (@json, '$[0]') or openjson (@json, '$.structures[0]') I had this idea that I could read the values of the top level project objects along with the json string that represents the structures below it, which could then be parsed separately. The problem is that the following code does not work:

SQL Server OPENJSON read nested json

廉价感情. 提交于 2019-11-27 05:08:48
问题 I have some json that I would like to parse in SQL Server 2016. There is a hierarchy structure of Projects->Structures->Properties. I would like to write a query that parses the whole hierarchy but I don't want to specify any elements by index number ie I don't want to do anything like this: openjson (@json, '$[0]') or openjson (@json, '$.structures[0]') I had this idea that I could read the values of the top level project objects along with the json string that represents the structures