troubleshooting Question

Query Json file

Avatar of Leo Torres
Leo TorresFlag for United States of America asked on
Microsoft SQL ServerJSONSQL
7 Comments2 Solutions56 ViewsLast Modified:
I wan to query the Ticker, Status,queryCount, adjusted columns but I can't seem to be able to query the values inside result with the values outside that variable.


SELECT tbl.*
FROM OPENROWSET (BULK 'C:\SomeFile.json', SINGLE_CLOB) js
CROSS APPLY OPENJSON(BulkColumn)
WITH
(
	v NVARCHAR(MAX) '$.results' AS JSON
	
)
cross APPLY OPENJSON(v)
WITH
(
	
	[v] int,
	[vw] decimal(15,5),
	[o] decimal(15,5),
	[c] decimal(15,5),
	[h] decimal(15,5),
	[l] decimal(15,5),
	[t] bigint,
	[n] smallint
) tbl

Open in new window





this is my json file below

[{
        "ticker": "VIG",
        "status": "OK",
        "queryCount": 1571,
        "resultsCount": 1571,
        "adjusted": false,
        "results": [{
                "v": 117,
                "vw": 112.0438,
                "o": 112,
                "c": 112,
                "h": 112,
                "l": 112,
                "t": 1588330800000,
                "n": 5
            }

Open in new window

ASKER CERTIFIED SOLUTION
ste5an
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros