You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/sql-database/sql-database-json-features.md
+14-15Lines changed: 14 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ms.topic: conceptual
10
10
author: jovanpop-msft
11
11
ms.author: jovanpop
12
12
ms.reviewer:
13
-
ms.date: 01/15/2019
13
+
ms.date: 04/19/2019
14
14
---
15
15
# Getting started with JSON features in Azure SQL Database
16
16
Azure SQL Database lets you parse and query data represented in JavaScript Object Notation [(JSON)](https://www.json.org/) format, and export your relational data as JSON text. The following JSON scenarios are available in Azure SQL Database:
@@ -24,15 +24,15 @@ If you have a web service that takes data from the database layer and provides a
24
24
25
25
In the following example, rows from the Sales.Customer table are formatted as JSON by using the FOR JSON clause:
26
26
27
-
```
27
+
```sql
28
28
select CustomerName, PhoneNumber, FaxNumber
29
29
fromSales.Customers
30
30
FOR JSON PATH
31
31
```
32
32
33
33
The FOR JSON PATH clause formats the results of the query as JSON text. Column names are used as keys, while the cell values are generated as JSON values:
@@ -44,7 +44,7 @@ The result set is formatted as a JSON array where each row is formatted as a sep
44
44
45
45
PATH indicates that you can customize the output format of your JSON result by using dot notation in column aliases. The following query changes the name of the "CustomerName" key in the output JSON format, and puts phone and fax numbers in the "Contact" sub-object:
46
46
47
-
```
47
+
```sql
48
48
select CustomerName as Name, PhoneNumber as [Contact.Phone], FaxNumber as [Contact.Fax]
49
49
fromSales.Customers
50
50
where CustomerID =931
@@ -53,7 +53,7 @@ FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
53
53
54
54
The output of this query looks like this:
55
55
56
-
```
56
+
```json
57
57
{
58
58
"Name":"Nada Jovanovic",
59
59
"Contact":{
@@ -67,20 +67,19 @@ In this example, we returned a single JSON object instead of an array by specify
67
67
68
68
The main value of the FOR JSON clause is that it lets you return complex hierarchical data from your database formatted as nested JSON objects or arrays. The following example shows how to include the rows from the `Orders` table that belong to the `Customer` as a nested array of `Orders`:
69
69
70
-
```
70
+
```sql
71
71
select CustomerName as Name, PhoneNumber as Phone, FaxNumber as Fax,
Instead of sending separate queries to get Customer data and then to fetch a list of related Orders, you can get all the necessary data with a single query, as shown in the following sample output:
82
81
83
-
```
82
+
```json
84
83
{
85
84
"Name":"Nada Jovanovic",
86
85
"Phone":"(215) 555-0100",
@@ -89,7 +88,7 @@ Instead of sending separate queries to get Customer data and then to fetch a lis
@@ -98,7 +97,7 @@ If you don’t have strictly structured data, if you have complex sub-objects, a
98
97
99
98
JSON is a textual format that can be used like any other string type in Azure SQL Database. You can send or store JSON data as a standard NVARCHAR:
100
99
101
-
```
100
+
```sql
102
101
CREATETABLEProducts (
103
102
Id int identity primary key,
104
103
Title nvarchar(200),
@@ -114,7 +113,7 @@ END
114
113
115
114
The JSON data used in this example is represented by using the NVARCHAR(MAX) type. JSON can be inserted into this table or provided as an argument of the stored procedure using standard Transact-SQL syntax as shown in the following example:
@@ -125,7 +124,7 @@ If you have data formatted as JSON stored in Azure SQL tables, JSON functions le
125
124
126
125
JSON functions that are available in Azure SQL database let you treat data formatted as JSON as any other SQL data type. You can easily extract values from the JSON text, and use JSON data in any query:
@@ -143,7 +142,7 @@ The JSON_MODIFY function lets you specify the path of the value in the JSON text
143
142
144
143
Since JSON is stored in a standard text, there are no guarantees that the values stored in text columns are properly formatted. You can verify that text stored in JSON column is properly formatted by using standard Azure SQL Database check constraints and the ISJSON function:
145
144
146
-
```
145
+
```sql
147
146
ALTERTABLE Products
148
147
ADD CONSTRAINT [Data should be formatted as JSON]
149
148
CHECK (ISJSON(Data) >0)
@@ -162,7 +161,7 @@ In the example above, we can specify where to locate the JSON array that should
162
161
163
162
We can transform a JSON array in the @orders variable into a set of rows, analyze this result set, or insert rows into a standard table:
The collection of orders formatted as a JSON array and provided as a parameter to the stored procedure can be parsed and inserted into the Orders table.
> The Managed Instance Contributor role does not have permission to delete LTR backups.
47
45
48
46
RBAC permissions could be granted in either *subscription* or *resource group* scope. However, to access LTR backups that belong to a dropped instance, the permission must be granted in the *subscription* scope of that instance.
# create LTR policy with WeeklyRetention = 12 weeks, YearlyRetention = 5 years and WeekOfYear = 16 (week of April 15). MonthlyRetention = 0 by default.
Copy file name to clipboardExpand all lines: articles/sql-database/sql-database-monitoring-with-dmvs.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ms.topic: conceptual
10
10
author: juliemsft
11
11
ms.author: jrasnick
12
12
ms.reviewer: carlrab
13
-
ms.date: 03/10/2020
13
+
ms.date: 04/19/2020
14
14
---
15
15
# Monitoring performance Azure SQL Database using dynamic management views
16
16
@@ -598,7 +598,7 @@ The next example shows you different ways that you can use the **sys.resource_st
598
598
599
599
3. With this information about the average and maximum values of each resource metric, you can assess how well your workload fits into the compute size you chose. Usually, average values from **sys.resource_stats** give you a good baseline to use against the target size. It should be your primary measurement stick. For an example, you might be using the Standard service tier with S2 compute size. The average use percentages for CPU and IO reads and writes are below 40 percent, the average number of workers is below 50, and the average number of sessions is below 200. Your workload might fit into the S1 compute size. It's easy to see whether your database fits in the worker and session limits. To see whether a database fits into a lower compute size with regards to CPU, reads, and writes, divide the DTU number of the lower compute size by the DTU number of your current compute size, and then multiply the result by 100:
600
600
601
-
```S1 DTU / S2 DTU * 100 = 20 / 50 * 100 = 40```
601
+
`S1 DTU / S2 DTU * 100 = 20 / 50 * 100 = 40`
602
602
603
603
The result is the relative performance difference between the two compute sizes in percentage. If your resource use doesn't exceed this amount, your workload might fit into the lower compute size. However, you need to look at all ranges of resource use values, and determine, by percentage, how often your database workload would fit into the lower compute size. The following query outputs the fit percentage per resource dimension, based on the threshold of 40 percent that we calculated in this example:
0 commit comments