|
1 |
| -# SQLDBA-SSMS-Solution |
| 1 | +# Custom Log Shipping Script |
2 | 2 |
|
3 |
| -This is SQL Server Management Solution containing various projects having SQL scripts to help DBA in carrying out daily activities. Below are some highlights:- |
| 3 | +When it comes to Disaster Recovery Setup, every DBA has its own preference. I personally prefer Log Shipping since it involves very little effort to setup. Log shipping has many benefits as stated below:- |
4 | 4 |
|
5 |
| -### 1. Backup-Restore |
6 |
| -This project contains Scripts for SQL Server Instance/Database migration. Following are the files:- |
7 |
| -``` |
8 |
| -1) Generate - Backup Script.sql |
9 |
| -2) Script Out DB Permissions in case of DB Refresh.sql |
10 |
| -3) Generate - Restore Script.sql |
11 |
| -4) Script Out DB_Owner from Source.sql |
12 |
| -5) Set Compatibility Level as per Model.sql |
13 |
| -6) Execute CheckDB _ UpdateStats for Migrated DBs.sql |
14 |
| -7) Copy Latest Full backup to Location - Reading BackupFile.sql |
15 |
| -7) Copy Latest Full backup to Location - Using BackupHistory.sql |
16 |
| -8) Fix Orphan Logins for All DBs.sql |
17 |
| -Query - Backup History.sql |
18 |
| -Query - Restore History.sql |
19 |
| -``` |
| 5 | +1. Multiple Secondary copies with different delay and uses |
| 6 | +2. Can be used as Disaster Recovery Technique |
| 7 | +3. Can be used for Limited Reporting Workload |
| 8 | +4. Can be used to migrate data to a new location with minimum downtime |
| 9 | +5. SQL Server Upgrade |
| 10 | +6. No additional load on Primary instance |
| 11 | +7. Works well in combination with other HADR features like Mirroring, AlwaysOn, Clustering etc. |
20 | 12 |
|
21 |
| -### 2. BlitzQueries |
22 |
| -This project contains script files that can be used for Health Checkup or Performance Troubleshooting of SQL Server. File `Other queries.sql` within this project contains TSQL code to find variety of informations like:- |
23 |
| -``` |
24 |
| -- Check when SQL Services were started |
25 |
| -- Check if compatibility Model of databases are up to date |
26 |
| -- Ad hoc queries, and m/r settings |
27 |
| -- Find queries using DBCC commands inside them |
28 |
| -- Find Most Expensive Queries |
29 |
| -- Top Queries by Average IO |
30 |
| -- Expensive Queries Having Cursor |
31 |
| -- Expensive Queries Having Joins to Table-Valued Functions |
32 |
| -- Queries with implicit conversion |
33 |
| -- Adhoc queries against Database |
34 |
| -- Find queries with multiple plans |
35 |
| -- Query to examine IO subsystem latencies |
36 |
| -- Active tables without clustered index |
37 |
| -- Find tables with forwarded records on Single Database |
38 |
| -- Find tables with forwarded records on All Databases |
39 |
| -- Find Query with Compilation Timeout |
40 |
| -- Find all disabled indexes |
41 |
| -- Get Cumulative Waits on Server |
42 |
| -- Find Un-trusted Foreign Keys |
43 |
| -- Find Usage Stats for Table and Indexes |
44 |
| -``` |
45 |
| -It also contains scripts for finding `WhatIsRunning` and also modified version of `sp_WhoIsActive`. |
46 |
| -Screenshot for **`WhatIsRunning.sql`**:- |
47 |
| - |
| 13 | +But If you use Domain Account for SQL Services, then Log Shipping using Custom scripts could be established in much easier way than the default log shipping method. For this purpose, I have created by own Log Shipping procedure [dbo].[usp_DBAApplyTLogs] |
48 | 14 |
|
49 |
| -Screenshot for modified versin of **`who_is_active_v11_30`**:- |
50 |
| - |
| 15 | +<b> [Latest Code of [usp_DBAApplyTLogs]](usp_DBAApplyTLogs.sql)</b> |
51 | 16 |
|
52 |
| -### 3. [sp_HealthCheck] |
53 |
| -This project contains a procedure named [sp_HealthCheck] This procedure gives `currently running queries`, `CPU and Memory usage`, `Usage of Data & Log Volumes`, `Space utilization of data/log files`, `Lead Blockers`, and `session details performing Backup/Restore/Rollback`. |
| 17 | +To learn on how to use this script, please watch below YouTube video:- |
54 | 18 |
|
55 |
| - |
56 |
| - |
57 |
| -### 4. Custom Log Shipping Script |
58 |
| -Log Shipping has many benefits and is often used a Disaster Recovery option. But, If you use Domain Account for SQL Services, then Log Shipping using Custom scripts could be established in much easier way than the default log shipping method. For this purpose, I have created by own Log Shipping procedure [dbo].[usp_DBAApplyTLogs] |
59 |
| - |
60 |
| -<b> [Latest Code of [usp_DBAApplyTLogs]](SQLDBA-SSMS-Solution/LogShipping/usp_DBAApplyTLogs.sql)</b> |
| 19 | +[](https://youtu.be/vF-EsyHnFRk) |
61 | 20 |
|
0 commit comments