This commit is contained in:
Bob Ward 2023-04-04 16:15:47 -06:00
Родитель c1b640283d
Коммит 9718f604b8
13 изменённых файлов: 145 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,29 @@
USE msdb;
GO
DECLARE @jobId BINARY(16)
EXEC msdb.dbo.sp_add_job @job_name=N'dbccjob',
@enabled=1,
@notify_level_eventlog=0,
@notify_level_email=0,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'No description available.',
@category_name=N'[Uncategorized (Local)]',
@owner_login_name=N'sqladmin', @job_id = @jobId OUTPUT;
EXEC msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'step1',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'DBCC CHECKDB(todo)',
@database_name=N'master',
@flags=0;
EXEC msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1;
EXEC msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)';
GO

Просмотреть файл

@ -0,0 +1,10 @@
USE master;
GO
DROP DATABASE IF EXISTS todo_archive;
GO
CREATE DATABASE todo_archive;
GO
USE todo_archive;
GO
SELECT * FROM todo.dbo.todolist;
GO

Просмотреть файл

@ -0,0 +1,2 @@
SELECT name, compatibility_level FROM sys.databases WHERE name = 'todo';
GO

Просмотреть файл

@ -0,0 +1,4 @@
SELECT * FROM sys.dm_exec_requests;
GO
SELECT * FROM sys.dm_os_wait_stats;
GO

Просмотреть файл

@ -0,0 +1,19 @@
ALTER DATABASE [todo]
SET QUERY_STORE = ON
(
OPERATION_MODE = READ_WRITE,
CLEANUP_POLICY = ( STALE_QUERY_THRESHOLD_DAYS = 90 ),
DATA_FLUSH_INTERVAL_SECONDS = 900,
MAX_STORAGE_SIZE_MB = 1000,
INTERVAL_LENGTH_MINUTES = 60,
SIZE_BASED_CLEANUP_MODE = AUTO,
MAX_PLANS_PER_QUERY = 200,
WAIT_STATS_CAPTURE_MODE = ON,
QUERY_CAPTURE_MODE = CUSTOM,
QUERY_CAPTURE_POLICY = (
STALE_CAPTURE_POLICY_THRESHOLD = 24 HOURS,
EXECUTION_COUNT = 30,
TOTAL_COMPILE_CPU_TIME_MS = 1000,
TOTAL_EXECUTION_CPU_TIME_MS = 100
)
);

Просмотреть файл

@ -0,0 +1,15 @@
## Demo for compatibility of Azure SQL Managed Instance compared to SQL Server
This is a demo for compatibility of Azure SQL Managed Instance compared to SQL Server. You must have completed the exercises for online_migration before performing these demo steps.
## Steps
Follow these steps to show the compatibility of Azure SQL Managed Instance compared to SQL Server. Connect to SSMS to Azure SQL Managed Instance.
1. Load and execute the script **dbcompat.sql** to show the dbcompat level from the SQL Server 2019 database was maintained.
1. Load and execute the script **createagentjob.sql**. Notice the job has a T-SQL step to execute DBCC CHECKDB on the user database created as part of this demo.
1. Load and execute the script **dmvs.sql** to show common DMVs are available.
1. Load and execute **crossdb.sql** to show you can create new databases and execute cross-database queries.
1. Load and execute **querystore.sql** to show you can enable the Query Store and set all the options from SQL Server.
1. Using SSMS and Object Explorer, double-click on Standard under XEvent Profile to show you can use Extended Events in Managed Instance and even get a quick Live Watch of SQL activity.

Просмотреть файл

@ -0,0 +1,6 @@
-- Run on SQL Server
-- Create a master key
USE MASTER;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '$StrongPassw0rd';
GO

Просмотреть файл

@ -0,0 +1,7 @@
-- Run on SQL Server
-- Set full recovery mode for all databases you want to replicate.
ALTER DATABASE todo SET RECOVERY FULL;
GO
-- Execute backup for all databases you want to replicate.
BACKUP DATABASE todo TO DISK = N'C:\backups\todo.bak';
GO

Просмотреть файл

@ -0,0 +1,11 @@
SELECT @@SERVERNAME AS SERVERNAME, CASE
WHEN SERVERPROPERTY('EngineEdition') < 5 THEN 'SQL Server'
WHEN SERVERPROPERTY('EngineEdition') = 8 THEN 'Azure SQL Mananaged Instance'
END
GO
SELECT DATABASEPROPERTYEX('todo', 'Updateability');
GO
USE todo;
GO
SELECT COUNT(*) FROM todolist;
GO

Просмотреть файл

@ -4,7 +4,23 @@ This is a demo for an online migration from SQL Server 2019 to Azure SQL Managed
## Steps
Follow these steps to show an online migration from SQL Server 2019 to Azure SQL Managed Instance
### Synchronize SQL Server 2019 to Azure SQL Managed Instance
Follow these steps to synchronize your database to Azure SQL Managed Instance. After you sync the database see how you can use the Azure SQL Managed Instance
1. Carefully go through all the steps to prepare your SQL Server 2019 and Azure SQL Managed Instance to use the Managed Instance Link feature: <https://learn.microsoft.com/azure/azure-sql/managed-instance/managed-instance-link-preparation?view=azuresql>
> **Note:** Using the Azure marketplace for SQL Server 2019 automatically applies the latest CU for SQL Server 2019.
1. Follow these steps in SSMS to replicate the new database from SQL Server 2019 to Azure SQL Managed Instance: <https://learn.microsoft.com/azure/azure-sql/managed-instance/managed-instance-link-use-ssms-to-replicate-database?view=azuresql>
1. Connect to both SSMS and Azure SQL Managed Instance using SSMS so you see both connections in Object Explorer. Notice the database is marked Synchronized after you replicate it to Azure SQL Managed Instance. Notice also the database exists in Object Explore in the context of the Managed Instance.
1. Open the script **getrowcount.sql** for both SQL Server 2019 and Azure SQL Managed Instance. You can see the rowcounts for the todolist table are the same. You can also see the *updateability* of the todo database is READ_WRITE for SQL Server 2019 and READ_ONLY for Managed Instance. This shows the table data is synchronized.
1. Open up the script **write_workload.sql** connected to SQL Server 2019 and execute it. Now execute **getrowcount.sql** for Managed Instance. You can now see rowcount changes occur and shows you can use Managed Instance as a read replica while you are in the process of preparing to migrate.
1. Cancel the query execution for **write_workload.sql** to stop the write workload as you prepare to migrate.

Просмотреть файл

@ -0,0 +1,23 @@
-- Perform writes
--
SELECT @@SERVERNAME AS SERVERNAME, CASE
WHEN SERVERPROPERTY('EngineEdition') < 5 THEN 'SQL Server'
WHEN SERVERPROPERTY('EngineEdition') = 8 THEN 'Azure SQL Mananaged Instance'
END
GO
SELECT DATABASEPROPERTYEX('todo', 'Updateability');
GO
USE todo;
GO
SET NOCOUNT ON;
GO
DECLARE @x int;
SET @x = 0;
WHILE (@x < 10000000)
BEGIN
INSERT INTO todolist (list_item, list_assigned) VALUES ('New todolist item', user_name());
SET @x = @x + 1;
END;
GO
SET NOCOUNT OFF;
GO

Просмотреть файл

@ -20,14 +20,15 @@ In this example you will learn how to:
## Setup
Follow the instructions at
Follow the instructions at <https://github.com/microsoft/bobsql/blob/master/demos/sqlmidemo/setup/readme.md>.
## Perform an online migration from SQL Server 2019 to Azure SQL Managed Instance
Execute all the steps in the **online_migration\readme.md** file.
Execute all the steps in the **online_migration\readme.md** file to perform an online migration to Azure SQL Managed Instance.
## See the compatibility between SQL Server and Azure SQL Managed Instance.
Execute all the steps in the **compat\readme.md** folder. You must have completed the online_migration steps prior to this set of examples.
## Optimize costs and do more with less using the cloud with Azure SQL Managed Instance.

Просмотреть файл