├── cover.png ├── Chapter 2 Installing and Configuring SQL Server on Azure VMs ├── Provisioning of SQL Server Azure VM.ps1 └── Attaching Multiple Disks for SQL Server VM.ps1 ├── Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database ├── Provisioning an Azure SQL Database.ps1 ├── Configuring Server Level Firewall using Azure PowerShell.ps1 ├── Configuring Server Level Firewall using Transact SQL.sql ├── Configuring Database Level Firewall using Transact SQL.sql └── Managing Azure SQL Database using T-SQL.sql ├── Chapter 4 Performance Considerations for SQL Server on Azure VMs └── Creating Storage Pool for SQL Server Data and Log Files in Azure VM.ps1 ├── README.md └── Chapter 8 Performance Considerations for Azure SQL Database ├── Monitoring unused Indexes using DMV.sql ├── Monitoring Resource Usage using DMV.sql └── Monitoring Missing Indexes using DMV.sql /cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyncfusionSuccinctlyE-Books/SQL-on-Azure-Succinctly/HEAD/cover.png -------------------------------------------------------------------------------- /Chapter 2 Installing and Configuring SQL Server on Azure VMs/Provisioning of SQL Server Azure VM.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyncfusionSuccinctlyE-Books/SQL-on-Azure-Succinctly/HEAD/Chapter 2 Installing and Configuring SQL Server on Azure VMs/Provisioning of SQL Server Azure VM.ps1 -------------------------------------------------------------------------------- /Chapter 2 Installing and Configuring SQL Server on Azure VMs/Attaching Multiple Disks for SQL Server VM.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyncfusionSuccinctlyE-Books/SQL-on-Azure-Succinctly/HEAD/Chapter 2 Installing and Configuring SQL Server on Azure VMs/Attaching Multiple Disks for SQL Server VM.ps1 -------------------------------------------------------------------------------- /Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database/Provisioning an Azure SQL Database.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyncfusionSuccinctlyE-Books/SQL-on-Azure-Succinctly/HEAD/Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database/Provisioning an Azure SQL Database.ps1 -------------------------------------------------------------------------------- /Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database/Configuring Server Level Firewall using Azure PowerShell.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyncfusionSuccinctlyE-Books/SQL-on-Azure-Succinctly/HEAD/Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database/Configuring Server Level Firewall using Azure PowerShell.ps1 -------------------------------------------------------------------------------- /Chapter 4 Performance Considerations for SQL Server on Azure VMs/Creating Storage Pool for SQL Server Data and Log Files in Azure VM.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyncfusionSuccinctlyE-Books/SQL-on-Azure-Succinctly/HEAD/Chapter 4 Performance Considerations for SQL Server on Azure VMs/Creating Storage Pool for SQL Server Data and Log Files in Azure VM.ps1 -------------------------------------------------------------------------------- /Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database/Configuring Server Level Firewall using Transact SQL.sql: -------------------------------------------------------------------------------- 1 | --Create New Firewall rule 2 | EXEC sp_set_firewall_rule @name = N'DBAFirewallRule', @start_ip_address = '172.16.1.1', @end_ip_address = '172.16.1.10' 3 | -- Update an existing Firewall rule 4 | EXEC sp_set_firewall_rule @name = N'DBAFirewallRule', @start_ip_address = '172.16.1.4', @end_ip_address = '172.16.1.10' 5 | --Delete an existing Firewall rule 6 | EXEC sp_delete_firewall_rule @name = N'DBAFirewallRule' 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQL on Azure Succinctly 2 | 3 | This is the companion repo for [*SQL on Azure Succinctly*](https://www.syncfusion.com/ebooks/sqlazure) by Parikshit Savjani. Published by Syncfusion. 4 | 5 | [![cover](https://github.com/SyncfusionSuccinctlyE-Books/SQL-on-Azure-Succinctly/blob/master/cover.png)](https://www.syncfusion.com/ebooks/sqlazure) 6 | 7 | ## Looking for more _Succinctly_ titles? 8 | 9 | Check out the entire library of more than 130 _Succinctly_ e-books at [https://www.syncfusion.com/ebooks](https://www.syncfusion.com/ebooks). 10 | 11 | -------------------------------------------------------------------------------- /Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database/Configuring Database Level Firewall using Transact SQL.sql: -------------------------------------------------------------------------------- 1 | --Create New Database Level Firewall rule 2 | EXEC sp_set_database_firewall_rule @name = N'ApplicationFirewallRule', @start_ip_address = '172.16.1.11', @end_ip_address = '172.16.1.11' 3 | -- Update an existing Database Level Firewall rule 4 | EXEC sp_set_database_firewall_rule @name = N'ApplicationFirewallRule', @start_ip_address = '172.16.1.11', @end_ip_address = '172.16.1.12' 5 | --Delete an existing Firewall rule 6 | EXEC sp_delete_database_firewall_rule @name = N'ApplicationFirewallRule' 7 | -------------------------------------------------------------------------------- /Chapter 8 Performance Considerations for Azure SQL Database/Monitoring unused Indexes using DMV.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | DB_NAME() AS DatabaseName, 3 | OBJECT_NAME(i.OBJECT_ID) AS TableName , 4 | i.name AS IndexName, 5 | s.user_updates AS IndexUserUpdates 6 | 7 | FROM sys.indexes i 8 | LEFT JOIN sys.dm_db_index_usage_stats s 9 | ON s.OBJECT_ID = i.OBJECT_ID 10 | AND i.index_id = s.index_id 11 | AND s.database_id = DB_ID() 12 | WHERE OBJECTPROPERTY(i.OBJECT_ID, 'IsIndexable') = 1 13 | -- index_usage_stats has no reference to this index (not being used) 14 | AND s.index_id IS NULL 15 | -- index is being updated, but not used by seeks/scans/lookups 16 | OR ( 17 | s.user_updates > 0 18 | AND s.user_seeks = 0 19 | AND s.user_scans = 0 20 | AND s.user_lookups = 0 21 | ) 22 | ORDER BY OBJECT_NAME(i.OBJECT_ID) ASC 23 | -------------------------------------------------------------------------------- /Chapter 7 Provisioning, Managing & Migrating to Azure SQL Database/Managing Azure SQL Database using T-SQL.sql: -------------------------------------------------------------------------------- 1 | -- Create New Database 2 | CREATE DATABASE myTestDB 3 | ( 4 | EDITION='Standard', 5 | SERVICE_OBJECTIVE='S0' 6 | ); 7 | -- ALTER DATABASE 8 | ALTER DATABASE myTestDB 9 | MODIFY 10 | ( 11 | SERVICE_OBJECTIVE='S1' 12 | ); 13 | -- DROP DATABASE 14 | DROP DATABASE myTestDB; 15 | -- Create New Server Login 16 | CREATE LOGIN User1 WITH password='Password1'; 17 | -- Create Database User (Switch to User Database) 18 | CREATE USER dbuser1 FROM LOGIN User1; 19 | --Adding User to db_datareader role (Switch to User Database) 20 | exec sp_addrolemember 'db_datareader', 'dbuser1'; 21 | -- DROP Login (Switch to master Database) 22 | DROP LOGIN User1 23 | -- Query Catalog Views (on Master database) 24 | SELECT * FROM sys.databases 25 | SELECT * FROM sys.sql_logins 26 | -- Query Dynamic Management Views (On User database) 27 | SELECT text,* from sys.dm_exec_requests 28 | cross apply sys.dm_exec_sql_text(sql_handle) 29 | SELECT * from sys.dm_exec_connections 30 | SELECT * from sys.dm_exec_sessions 31 | -------------------------------------------------------------------------------- /Chapter 8 Performance Considerations for Azure SQL Database/Monitoring Resource Usage using DMV.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | FROM sys.resource_stats 3 | WHERE database_name = 'myazuresqldb' AND 4 | start_time > DATEADD(day, -7, GETDATE()) 5 | ORDER BY start_time DESC; 6 | 7 | SELECT 8 | avg(avg_cpu_percent) AS 'Average CPU Utilization In Percent', 9 | max(avg_cpu_percent) AS 'Maximum CPU Utilization In Percent', 10 | avg(avg_physical_data_read_percent) AS 'Average Physical Data Read Utilization In Percent', 11 | max(avg_physical_data_read_percent) AS 'Maximum Physical Data Read Utilization In Percent', 12 | avg(avg_log_write_percent) AS 'Average Log Write Utilization In Percent', 13 | max(avg_log_write_percent) AS 'Maximum Log Write Utilization In Percent', 14 | avg(active_session_count) AS 'Average # of Sessions', 15 | max(active_session_count) AS 'Maximum # of Sessions', 16 | avg(active_worker_count) AS 'Average # of Workers', 17 | max(active_worker_count) AS 'Maximum # of Workers' 18 | FROM sys.resource_stats 19 | WHERE database_name = 'myazuresqldb' AND start_time > DATEADD(day, -7, GETDATE()); 20 | -------------------------------------------------------------------------------- /Chapter 8 Performance Considerations for Azure SQL Database/Monitoring Missing Indexes using DMV.sql: -------------------------------------------------------------------------------- 1 | SELECT CONVERT (varchar, getdate(), 126) AS runtime, 2 | mig.index_group_handle, mid.index_handle, 3 | CONVERT (decimal (28,1), migs.avg_total_user_cost * migs.avg_user_impact * 4 | (migs.user_seeks + migs.user_scans)) AS improvement_measure, 5 | 'CREATE INDEX missing_index_' + CONVERT (varchar, mig.index_group_handle) + '_' + 6 | CONVERT (varchar, mid.index_handle) + ' ON ' + mid.statement + ' 7 | (' + ISNULL (mid.equality_columns,'') 8 | + CASE WHEN mid.equality_columns IS NOT NULL 9 | AND mid.inequality_columns IS NOT NULL 10 | THEN ',' ELSE '' END + ISNULL (mid.inequality_columns, '') 11 | + ')' 12 | + ISNULL (' INCLUDE (' + mid.included_columns + ')', '') AS create_index_statement, 13 | migs.*, 14 | mid.database_id, 15 | mid.[object_id] 16 | FROM sys.dm_db_missing_index_groups AS mig 17 | INNER JOIN sys.dm_db_missing_index_group_stats AS migs 18 | ON migs.group_handle = mig.index_group_handle 19 | INNER JOIN sys.dm_db_missing_index_details AS mid 20 | ON mig.index_handle = mid.index_handle 21 | ORDER BY migs.avg_total_user_cost * migs.avg_user_impact * (migs.user_seeks + migs.user_scans) DESC 22 | --------------------------------------------------------------------------------