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: 0_Azure/2_AzureAnalytics/1_SynapseAnalytics/demos/2_synapse_views_dynamically_remove_space/0_serverlessSQLPool/README.md
<summary><b>List of References </b> (Click to expand)</summary>
16
+
<summary><b>Table of Content </b> (Click to expand)</summary>
17
17
18
+
-[Content](#content)
19
+
-[Overview](#overview)
20
+
-[Demo](#demo)
21
+
-[Set Up a Synapse Workspace](#set-up-a-synapse-workspace)
22
+
-[Upload Sample Data to Storage Account](#upload-sample-data-to-storage-account)
23
+
-[Create User Database](#create-user-database)
24
+
-[Create an External Data Source and File Format](#create-an-external-data-source-and-file-format)
25
+
-[Create an External Table](#create-an-external-table)
26
+
-[Create Views with Modified Tables/Column Names](#create-views-with-modified-tablescolumn-names)
18
27
19
28
</details>
20
29
21
-
## Content
30
+
## Overview
22
31
23
-
<details>
24
-
<summary><b>Table of Content </b> (Click to expand)</summary>
32
+
> [!IMPORTANT]
33
+
> The serverless SQL pool in Azure Synapse Analytics `does not support internal tables. It primarily supports external tables and temporary tables`.
34
+
> For `internal tables,` you would need to use a `dedicated SQL pool` in Synapse Analytics, which allows you to `create and manage internal tables with local storage`.
|**External Tables**| - Reference data stored in external sources like Azure Data Lake Storage, Azure Blob Storage, Azure Cosmos DB, etc. <br> - Data is not physically stored in the SQL pool. <br> - Useful for querying large datasets without loading them into the SQL pool. | - Querying large datasets stored externally. <br> - Performing data analysis on data stored in various formats. |
39
+
|**Temporary Tables**| - Created and used within the scope of a session. <br> - Data is stored temporarily and is dropped when the session ends. <br> - Useful for intermediate data processing and transformations. | - Storing intermediate results during complex queries. <br> - Performing temporary data transformations and aggregations. |
26
40
27
-
</details>
28
41
42
+
## Demo
43
+
44
+
### Set Up a Synapse Workspace
45
+
46
+
1.**Sign in to the Azure Portal**: Go to the Azure Portal and sign in with your Azure account.
47
+
2.**Navigate to Your Synapse Workspace**: In the Azure Portal, search for your Synapse workspace or create a new one if you don't have one.
> For this demo, `we'll be using the same storage account created with the synpase workspace`.
65
+
> `CREATE EXTERNAL DATA SOURCE is not supported in the master database of the serverless` SQL pool. Instead, you `need to create a user database and perform the operations there`.
66
+
67
+
1. Create a Container in the Storage Account:
68
+
- Go to the Azure portal and navigate to your storage account.
69
+
- In the left-hand menu, select `Containers`.
70
+
- Click on `+ Container` to create a new container.
71
+
- Enter a name for the container, such as `sample-tables-container`.
72
+
- Set the `Public access level` to your preference (e.g., Private).
3. **Query the External Table**: You can now query the external table to see the sample data.
174
+
175
+
```sql
176
+
SELECT * FROM {Table Name};
177
+
```
178
+
179
+
### Create Views with Modified Tables/Column Names
180
+
181
+
> This script is designed to dynamically create views for each table in a database, renaming columns to remove spaces. It starts by creating a temporary table to store the SQL statements and assigns a unique row number to each statement. The script then loops through these statements, executing each one in turn. Finally, it cleans up by dropping the temporary table.
182
+
>1. **Temporary Table Creation**: A temporary table `#CreateViewStatements` is created to store the dynamic SQL statements and their corresponding row numbers. <br/>
183
+
>2. **Inserting SQL Statements**: The script generates SQL statements to create views for each table in the database. It uses the `INFORMATION_SCHEMA.COLUMNS` to get the table and column names, renaming columns to remove spaces. These statements, along with a row number, are inserted into the temporary table. <br/>
184
+
>3. **Variable Declaration**: Variables are declared to hold the current SQL statement, the current row number, and the maximum row number. <br/>
185
+
>4. **Getting Maximum Row Number**: The script retrieves the maximum row numberfrom the temporary table to determine how many statements need to be executed. <br/>
186
+
>5. **Executing SQL Statements**: A loop iterates through each row in the temporary table, retrieves the SQL statement, executes it, and increments the row number until all statements are executed. <br/>
187
+
>6. **Cleanup**: The temporary table is dropped to clean up after the script has finished executing. <br/>
188
+
189
+
```sql
190
+
-- Create a temporary table to store the dynamic SQL statements
Copy file name to clipboardExpand all lines: 0_Azure/2_AzureAnalytics/1_SynapseAnalytics/demos/2_synapse_views_dynamically_remove_space/1_dedicatedSQLPoolStoreProc/README.md
0 commit comments