JSON Support for SQL Server

Documentation › JsonBigInt

JsonBigInt(data, query) or JsonDataType QueryBigInt(query)

Query a 64-bit integer value stored within a JSON string.

Example

JsonBigInt(data, query)

JsonDataType QueryBigInt(query)

declare @orderData nvarchar(1000) set @orderData = '{ "Name": "Bob Smith", "ItemCount": 12, "Total": 15.54, "Packed": true, "Shipped": false, "OrderDate": "2015-02-10 14:52:23", "Lines": [ { "Item": "Hat", "Quantity": 10, "UnitPrice": 1.11, "Total": 11.1 }, { "Item": "Scarf", "Quantity": 2, "UnitPrice": 2.22, "Total": 4.44 } ] }' select dbo.JsonBigInt(@orderData, 'Lines[0].Quantity') as [Line 0 Quantity], dbo.JsonBigInt(@orderData, 'Lines[1].Quantity') as [Line 1 Quantity], dbo.JsonBigInt(@orderData, 'ItemCount') as [Total Count]

Results

Line 0 Quantity Line 1 Quantity Total Count
10 2 12

JsonDataType QueryBigInt(query)

declare @orderData json set @orderData = '{ "Name": "Bob Smith", "ItemCount": 12, "Total": 15.54, "Packed": true, "Shipped": false, "OrderDate": "2015-02-10 14:52:23", "Lines": [ { "Item": "Hat", "Quantity": 10, "UnitPrice": 1.11, "Total": 11.1 }, { "Item": "Scarf", "Quantity": 2, "UnitPrice": 2.22, "Total": 4.44 } ] }' select @orderData.QueryBigInt('Lines[0].Quantity') as [Line 0 Quantity], @orderData.QueryBigInt('Lines[1].Quantity') as [Line 1 Quantity], @orderData.QueryBigInt('ItemCount') as [Total Count]

Results

Line 0 Quantity Line 1 Quantity Total Count
10 2 12