Last modified by Rudi Marais on 2024/03/28 18:51

<
From version < 5.1 >
edited by Rudi Marais
on 2023/07/21 18:49
To version < 8.14 >
edited by Rudi Marais
on 2024/03/28 18:29
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,15 +1,25 @@
1 -* compressed file
2 -* contains ddl and dml data
3 -* doesnt support encrypted objects
4 -* cant have any stored procs with string that contain $( character sequence reserved sequence
5 -** break up sequence ie 'test$(test' become 'test$' + '(test'
6 -* [[https:~~/~~/learn.microsoft.com/en-us/azure/azure-sql/database/database-import>>https://learn.microsoft.com/en-us/azure/azure-sql/database/database-import]]
1 +
2 +
7 7  * sqlpackage
8 8  ** [[https:~~/~~/download.microsoft.com/download/7/c/8/7c877288-a0d9-4d22-b1dc-2086e262d82f/x64/DacFramework.msi>>https://download.microsoft.com/download/7/c/8/7c877288-a0d9-4d22-b1dc-2086e262d82f/x64/DacFramework.msi]]
9 9  ** [[https:~~/~~/learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download>>https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download]]
10 10  ** C:\Program Files\Microsoft SQL Server\160\DAC\bin
11 -* turn off real time scan (anti virus)
12 12  
8 +
9 +1. scale db to accetable performance ie dtus 500
10 +1. turn off real time scan (anti virus)
11 +1. run bcp extract scripts [everest & docs parallel]
12 +11. extract run from smallest to largest table
13 +1. run schema extracts [not in parallel!]
14 +1. create db
15 +1. create schema
16 +11. prep scripts first
17 +11. document references
18 +11. make sure ddl audit triggers are disabled
19 +1. run imports [parallel]
20 +11. imports runs from smallest to largest table
21 +
22 +
13 13  1. run extract with [[sql-script-db.ps1>>doc:technical-documentation.Source Control.migration.sql.sql-db-export.WebHome]] with validate set to true and raw objects set to true, only need tbl-triggers, functions and sp
14 14  11. reason for this is to identify any procedure/triggers/functions that dont compile
15 15  1. once this is done examine results and fix stored procedures on database so that they can compile, ie add missing columns or modify code to not require them
... ... @@ -22,15 +22,84 @@
22 22  1. run dacpac publish to managed instance
23 23  1.
24 24  
25 -= =
35 +* (((
36 +(% class="wikigeneratedid" id="Hhttps:2F2Fgithub.com2Fmicrosoft2Fmssql-scripter" %)
37 +[[https:~~/~~/github.com/microsoft/mssql-scripter>>https://github.com/microsoft/mssql-scripter]]
26 26  
39 +* C:\Users\alliancetest\.mssqlscripter
40 +* mssql-scripter -S "kula.database.windows.net" -d Everest_Test -U ebsadmin -P xxx -r -f E:\temp\khula_test.sql ~-~-display-progress ~-~-enable-toolsservice-logging
27 27  
42 +
43 +)))
44 +* ALTER DATABASE Everest_Test SET READ_ONLY WITH NO_WAIT
45 +
28 28  
47 +{{code language="sql"}}
48 +-- index
49 +select concat('echo ''',SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)), '.bcp ',SCHEMA_NAME(schema_id), '.', name , ''' >> test.log')
50 +from sys.tables
51 +where type = 'U'
52 +and is_ms_shipped = 0
53 +
54 +--and temporal_type in (0,2);
55 +
56 +-- export
57 +
58 +select '$path = "E:\temp\test\everest_test"' cmd union
59 +select '$server = "mytest.database.windows.net"' union
60 +select '$username = "sa"' union
61 +select '$password = "123456"' union
62 +select 'New-Item -ItemType Directory -Force -Path "$path\export_log"' union
63 +select 'New-Item -ItemType Directory -Force -Path "$path\data"'
64 +
65 +select export = concat('bcp "', DB_NAME(), '.',
66 + SCHEMA_NAME(schema_id), '.', replace(name,'$','`$'),
67 + '" out "$path\data\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)), '.bcp" ',
68 + ' -e "$path\export_log\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)), '.log" ',
69 + ' -S "', '$server','"',
70 + ' -N -U "$username" -P "$password"',
71 + ' | Out-Null')
72 +from sys.tables
73 +where type = 'U'
74 +and is_ms_shipped = 0
75 +--and temporal_type in (0,2);
76 +
77 +-- import
78 +
79 +select '$path = "E:\temp\test\everest_test"' cmd union
80 +select '$target_server = "sqlmi-ebs-prod.public.2a5fe6cde9a7.database.windows.net,3342"' union
81 +select '$target_db = "TST_Staging_Everest"' union
82 +select '$target_username = "import_test"' union
83 +select '$target_password = ''123456''' union
84 +select 'New-Item -ItemType Directory -Force -Path "$path\import_log"' union
85 +select 'New-Item -ItemType Directory -Force -Path "$path\data"'
86 +
87 +select import = concat('bcp "', '$target_db', '.',
88 + SCHEMA_NAME(schema_id), '.', replace(name,'$','`$'),
89 + '" in "$path\data\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)) , '.bcp" ',
90 + ' -e "$path\import_log\', SCHEMA_NAME(schema_id), '_', BASE64_ENCODE (cast(name as varbinary)) , '.log" ',
91 + ' -S "', '$target_server','"',
92 + ' -N -U "$target_username" -P "$target_password"',
93 + ' -b 1000 -E -k -N -q',
94 + ' | Out-Null')
95 +from sys.tables
96 +where type = 'U'
97 +and is_ms_shipped = 0
98 +--and temporal_type in (0,2);
99 +
100 +{{/code}}
101 +
102 +
103 +* disable anti-virus real time scan
104 +*
105 +
106 +(% class="wikigeneratedid" %)
107 +placeholder
108 +
29 29  = Exporting =
30 30  
31 31  * no encrypted objects, they need to be decrypted or removed prior to exporting.
32 32  
33 -
34 34  SQL 2012
35 35  
36 36  
... ... @@ -53,11 +53,23 @@
53 53  
54 54  BACKUP DATABASE Everest_TEST
55 55  TO DISK = N'O:\ENS_Everest_Test_20230721_1806.bak'
56 -WITH COMPRESSION;
135 +WITH COMPRESSION,
136 +STATS = 10;
137 +
138 +
57 57  GO
58 -
59 59  
60 60  
142 +SELECT 
143 + session_id as SPID, command, a.text AS Query, start_time, percent_complete,
144 + dateadd(second,estimated_completion_time/1000, getdate()) as estimated_completion_time
145 +FROM sys.dm_exec_requests r 
146 + CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a 
147 +WHERE r.command in ('BACKUP DATABASE','RESTORE DATABASE')
148 +
149 +GO
150 +
151 +
61 61  = Importing =
62 62  
63 63  
... ... @@ -72,5 +72,3 @@
72 72  * incubator/ebsphere.crm/ebs-devops-devops-sql/calc-signature-bacpac.ps1
73 73  * modify Origin.xml
74 74  ** Checksum attribute for model.xml
75 -
76 -

Need help?

If you need help with XWiki you can contact: