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
You can create reports from multiple databases from a single connection point using an [elastic query](elastic-query-overview.md). The databases must be horizontally partitioned (also known as "sharded").
17
20
18
-
If you have an existing database, see [Migrating existing databases to scaled-out databases](elastic-convert-to-use-elastic-tools.md).
21
+
If you have an existing database, see [Migrate existing databases to scale out](elastic-convert-to-use-elastic-tools.md).
19
22
20
-
To understand the SQL objects needed to query, see [Query across horizontally partitioned databases](elastic-query-horizontal-partitioning.md).
23
+
To understand the SQL objects needed to query, see [Reporting across scaled-out cloud databases (preview)](elastic-query-horizontal-partitioning.md).
21
24
22
25
## Prerequisites
23
26
24
-
Download and run the [Getting started with Elastic Database tools sample](elastic-scale-get-started.md).
27
+
Download and run the [Get started with Elastic Database Tools](elastic-scale-get-started.md).
25
28
26
29
## Create a shard map manager using the sample app
30
+
27
31
Here you will create a shard map manager along with several shards, followed by insertion of data into the shards. If you happen to already have shards setup with sharded data in them, you can skip the following steps and move to the next section.
28
32
29
33
1. Build and run the **Getting started with Elastic Database tools** sample application by following the steps in the article section [Download and run the sample app](elastic-scale-get-started.md#download-and-run-the-sample-app-1). Once you finish all the steps, you will see the following command prompt:
30
34
31
-
![command prompt][1]
32
-
2. In the command window, type "1" and press **Enter**. This creates the shard map manager, and adds two shards to the server. Then type "3" and press **Enter**; repeat the action four times. This inserts sample data rows in your shards.
33
-
3. The [Azure portal](https://portal.azure.com) should show three new databases in your server:
35
+
:::image type="content" source="media/elastic-query-getting-started/cmd-prompt.png" alt-text="Screenshot from the command prompt of the Elastic Database Tools starter kit.":::
34
36
35
-
![Visual Studio confirmation][2]
37
+
1. In the command window, type `1` and press **Enter**. This creates the shard map manager, and adds two shards to the server. Then type `3` and press **Enter**; repeat the action four times. This inserts sample data rows in your shards.
38
+
1. The [Azure portal](https://portal.azure.com) should show three new databases in your server:
36
39
37
-
At this point, cross-database queries are supported through the Elastic Database client libraries. For example, use option 4 in the command window. The results from a multi-shard query are always a **UNION ALL** of the results from all shards.
40
+
:::image type="content" source="media/elastic-query-getting-started/portal.png" alt-text="Screenshot of the Visual Studio confirmation creating three databases.":::
41
+
42
+
At this point, cross-database queries are supported through the Elastic Database client libraries. For example, use option `4` in the command window. The results from a multi-shard query are always a `UNION ALL` of the results from all shards.
38
43
39
44
In the next section, we create a sample database endpoint that supports richer querying of the data across shards.
40
45
41
46
## Create an elastic query database
42
47
43
48
1. Open the [Azure portal](https://portal.azure.com) and log in.
44
-
2. Create a new database in Azure SQL Database in the same server as your shard setup. Name the database "ElasticDBQuery."
49
+
1. Create a new database in Azure SQL Database in the same server as your shard setup. Name the database `ElasticDBQuery`.
45
50
46
-
![Azure portal and pricing tier][3]
51
+
You can use an existing database. If you can do so, it must not be one of the shards that you would like to execute your queries on. This database will be used for creating the metadata objects for an elastic database query.
47
52
48
-
> [!NOTE]
49
-
> you can use an existing database. If you can do so, it must not be one of the shards that you would like to execute your queries on. This database will be used for creating the metadata objects for an elastic database query.
50
-
>
51
53
52
54
## Create database objects
55
+
53
56
### Database-scoped master key and credentials
57
+
54
58
These are used to connect to the shard map manager and the shards:
55
59
56
60
1. Open SQL Server Management Studio or SQL Server Data Tools in Visual Studio.
57
-
2. Connect to ElasticDBQuery database and execute the following T-SQL commands:
61
+
1. Connect to `ElasticDBQuery` database and execute the following T-SQL commands:
58
62
59
63
```sql
60
64
CREATE MASTER KEY ENCRYPTION BY PASSWORD ='<master_key_password>';
@@ -64,10 +68,11 @@ These are used to connect to the shard map manager and the shards:
64
68
SECRET ='<password>';
65
69
```
66
70
67
-
"username"and"password" should be the same aslogin information used in step 3 of section [Download and run the sample app](elastic-scale-get-started.md#download-and-run-the-sample-app) in the **Getting started with Elastic Database tools** article.
71
+
Both "username"and"password" should be the login information you created inprevious steps.
68
72
69
73
### External data sources
70
-
To create an external data source, execute the following command on the ElasticDBQuery database:
74
+
75
+
To create an external data source, execute the following command on the `ElasticDBQuery` database:
71
76
72
77
```sql
73
78
CREATE EXTERNAL DATA SOURCE MyElasticDBQueryDataSrc WITH
@@ -79,10 +84,11 @@ CREATE EXTERNAL DATA SOURCE MyElasticDBQueryDataSrc WITH
79
84
) ;
80
85
```
81
86
82
-
"CustomerIDShardMap" is the name of the shard map, if you created the shard map and shard map manager using the elastic database tools sample. However, if you used your custom setup for this sample, then it should be the shard map name you chose in your application.
87
+
`CustomerIDShardMap` is the name of the shard map, if you created the shard map and shard map manager using the elastic database tools sample. However, if you used your custom setup for this sample, then it should be the shard map name you chose in your application.
83
88
84
89
### External tables
85
-
Create an external table that matches the Customers table on the shards by executing the following command on ElasticDBQuery database:
90
+
91
+
Create an external table that matches the Customers table on the shards by executing the following command on`ElasticDBQuery` database:
86
92
87
93
```sql
88
94
CREATE EXTERNAL TABLE [dbo].[Customers]
@@ -96,53 +102,45 @@ WITH
96
102
```
97
103
98
104
## Execute a sample elastic database T-SQL query
105
+
99
106
Once you have defined your external data source and your external tables you can now use full T-SQL over your external tables.
100
107
101
-
Execute this query on the ElasticDBQuery database:
108
+
Execute this query on the `ElasticDBQuery` database:
102
109
103
110
```sql
104
111
select count(CustomerId) from [dbo].[Customers]
105
112
```
106
113
107
114
You will notice that the query aggregates results from all the shards and gives the following output:
You can import the results from of a query to an Excel file.
113
119
114
-
1. Launch Excel 2013.
115
-
2. Navigate to the **Data** ribbon.
116
-
3. Click **From Other Sources**and click **From SQL Server**.
120
+
You can import the results from of a query to an Excel file.
117
121
118
-
![Excel import from other sources][5]
119
-
4. In the **Data Connection Wizard** type the server name and login credentials. Then click **Next**.
120
-
5. In the dialog box**Select the database that contains the data you want**, select the **ElasticDBQuery** database.
121
-
6. Select the **Customers** table in the list view and click **Next**. Then click **Finish**.
122
-
7. In the **Import Data** form, under **Select how you want to view this data in your workbook**, select**Table**and click **OK**.
122
+
1. Launch Microsoft Excel.
123
+
1. Navigate to the **Data** ribbon.
124
+
1. Select**From Other Sources**andselect**From SQL Server**.
125
+
1. In the **Data Connection Wizard** type the server name and login credentials. Then select**Next**.
126
+
1. In the dialog box**Select the database that contains the data you want**, select the `ElasticDBQuery` database.
127
+
1. Select the `Customers` table in the list view andselect**Next**. Then select**Finish**.
128
+
1. In the **Import Data** form, under **Select how you want to view this data in your workbook**, select**Table**andselect**OK**.
123
129
124
-
All the rows from**Customers** table, stored in different shards populate the Excel sheet.
130
+
All the rows from`Customers` table, stored in different shards populate the Excel sheet.
125
131
126
132
You can now use Excel's powerful data visualization functions. You can use the connection string with your server name, database name and credentials to connect your BI and data integration tools to the elastic query database. Make sure that SQL Server is supported as a data source for your tool. You can refer to the elastic query database and external tables just like any other SQL Server database and SQL Server tables that you would connect to with your tool.
127
133
128
134
### Cost
135
+
129
136
There is no additional charge for using the Elastic Database Query feature.
130
137
131
138
For pricing information see [SQL Database Pricing Details](https://azure.microsoft.com/pricing/details/sql-database/).
132
139
133
-
## Next steps
134
-
135
-
* For an overview of elastic query, see [Elastic query overview](elastic-query-overview.md).
136
-
* For a vertical partitioning tutorial, see [Getting started with cross-database query (vertical partitioning)](elastic-query-getting-started-vertical.md).
137
-
* For syntax and sample queries for vertically partitioned data, see [Querying vertically partitioned data)](elastic-query-vertical-partitioning.md)
138
-
* For syntax and sample queries for horizontally partitioned data, see [Querying horizontally partitioned data)](elastic-query-horizontal-partitioning.md)
139
-
* See [sp\_execute \_remote](/sql/relational-databases/system-stored-procedures/sp-execute-remote-azure-sql-database) for a stored procedure that executes a Transact-SQL statement on a single remote Azure SQL Database or set of databases serving as shards in a horizontal partitioning scheme.
0 commit comments