Skip to content

Commit 428a9fc

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents c39dfdf + 5ae9cf2 commit 428a9fc

29 files changed

+98917
-3218
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = tab
6+
end_of_line = crlf
7+
charset = utf-8
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
insert_final_newline = false

.github/ISSUE_TEMPLATE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**Do you want to request a *feature* or report a *bug*?**
2+
If you're reporting a bug, include the version number of the script you're using. If it's not the current version, upgrade to the current version and test that before reporting a bug - we fix a lot of stuff in each new build.
3+
4+
**What is the current behavior?**
5+
6+
**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via http://sqlfiddle.com**
7+
8+
**What is the expected behavior?**
9+
10+
**Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures?**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Fixes # .
2+
3+
Changes proposed in this pull request:
4+
-
5+
-
6+
-
7+
8+
How to test this code:
9+
-
10+
-
11+
-
12+
13+
Has been tested on (remove any that don't apply):
14+
- Case-sensitive SQL Server instance
15+
- SQL Server 2008
16+
- SQL Server 2008 R2
17+
- SQL Server 2012
18+
- SQL Server 2014
19+
- SQL Server 2016
20+
- Amazon RDS
21+
- Azure SQL DB

CONTRIBUTING.md

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ First of all, welcome! We're excited that you'd like to contribute. How would yo
77
* [I'd like to fix bugs in T-SQL checks](#how-to-fix-bugs-in-existing-t-sql-checks)
88
* [I'd like to test checks written by someone else](#how-to-test-checks-written-by-someone-else)
99
* [I'd like to write or update documentation](#how-to-write-or-update-documentation)
10+
* [I don't know how to upload code to GitHub](https://www.brentozar.com/archive/2015/07/pull-request-101-for-dbas-using-github/)
1011

1112
Everyone here is expected to abide by the [Contributor Covenant Code of Conduct](#the-contributor-covenant-code-of-conduct).
1213

13-
Wanna do something else, or have a question not answered here? Hop into Slack and ask us questions before you get started. [Join SQLServer.slack.com](https://sql-server-slack.herokuapp.com/), and we're in the [#FirstResponderKit channel](https://sqlserver.slack.com/messages/firstresponderkit/). We welcome newcomers, and there's always a way you can help.
14+
Wanna do something else, or have a question not answered here? Hop into Slack and ask us questions before you get started. [Get an invite to SQLCommunity.slack.com](https://sqlps.io/slack/), and we're in the [#FirstResponderKit channel](https://sqlcommunity.slack.com/messages/firstresponderkit/). We welcome newcomers, and there's always a way you can help.
1415

1516
## How to Report Bugs or Request Enhancements
1617

17-
[Check out the Github issues list.](https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues) Search for what you're interested in - there may already be an issue for it. Make sure to search through closed issues, too, because we often decline things that aren't a good fit for these tools.
18+
Check out the [Github issues list]. Search for what you're interested in - there may already be an issue for it. Make sure to search through closed issues, too, because we often decline things that aren't a good fit for these tools.
1819

1920
If you can't find a similar issue, go ahead and open your own. Include as much detail as you can - what you're seeing now, and what you'd like to see.
2021

@@ -24,11 +25,11 @@ When requesting new checks, keep in mind that we want to focus on:
2425
* Performance issues or reliability risks - if it's just a setting we don't agree with, let's set that aside
2526
* Things that end users or managers will notice - if we're going to have someone change a setting on their system, we want it to be worth their time
2627

27-
Now [head on over to the Github issues list](https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues) and get started.
28+
Now head on over to the [Github issues list] and get started.
2829

2930
## How to Write New T-SQL Checks
3031

31-
Before you code, check the [Github issues list](https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues) for what you're trying to do - there may already be an issue for it. Make sure to search through closed issues, too, because we often decline things that aren't a good fit for these tools.
32+
Before you code, check the [Github issues list] for what you're trying to do - there may already be an issue for it. Make sure to search through closed issues, too, because we often decline things that aren't a good fit for these tools.
3233

3334
If you've got a new idea that isn't covered in an existing issue, open a Github issue for it. Outline what you'd like to do, and how you'd like to code it. This just helps make sure other users agree that it's a good idea to add to these tools.
3435

@@ -100,5 +101,61 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai
100101
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
101102
available at [http://contributor-covenant.org/version/1/4][version]
102103

104+
105+
## Git Flow for pull requests
106+
<a name="git-flow"></a>
107+
108+
1. [Fork] the project, clone your fork, and configure the remotes:
109+
110+
```bash
111+
# Clone your fork of the repo into the current directory
112+
git clone [email protected]:<YOUR_USERNAME>/SQL-Server-First-Responder-Kit.git
113+
# Navigate to the newly cloned directory
114+
cd SQL-Server-First-Responder-Kit
115+
# Assign the original repo to a remote called "upstream"
116+
git remote add upstream https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/
117+
```
118+
119+
2. If you cloned a while ago, get the latest changes from upstream:
120+
121+
```bash
122+
git checkout master
123+
git pull upstream master
124+
```
125+
126+
3. Create a new topic branch (off the main project development branch) to
127+
contain your feature, change, or fix:
128+
129+
```bash
130+
git checkout -b <topic-branch-name>
131+
```
132+
133+
4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines]
134+
or your code is unlikely be merged into the main project. Use Git's [interactive rebase]
135+
feature to tidy up your commits before making them public.
136+
137+
5. Locally merge (or rebase) the upstream development branch into your topic branch:
138+
139+
```bash
140+
git pull [--rebase] upstream master
141+
```
142+
143+
6. Push your topic branch up to your fork:
144+
145+
```bash
146+
git push origin <topic-branch-name>
147+
```
148+
149+
7. [Open a Pull Request] with a clear title and description.
150+
151+
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the MIT [LICENSE]
152+
153+
103154
[homepage]: http://contributor-covenant.org
104-
[version]: http://contributor-covenant.org/version/1/4/
155+
[version]: http://contributor-covenant.org/version/1/4/
156+
[Github issues list]:https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues
157+
[Fork]:https://help.github.com/articles/fork-a-repo/
158+
[git commit message guidelines]:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
159+
[interactive rebase]:https://help.github.com/articles/about-git-rebase/
160+
[Open a Pull Request]:https://help.github.com/articles/about-pull-requests/
161+
[LICENSE]:https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/blob/master/LICENSE.md

sp_BlitzRS.sql renamed to Deprecated/sp_BlitzRS.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ IF OBJECT_ID('tempdb..#RoleTaskMask') IS NOT NULL
497497

498498
CREATE TABLE #RoleTaskMask
499499
(
500-
RoleName NVARCHAR(32) ,
500+
RoleName NVARCHAR(260) ,
501501
RoleFlags TINYINT ,
502502
TaskMaskPos TINYINT ,
503503
TaskMaskValue TINYINT
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ SET QUOTED_IDENTIFIER ON;
77
SET STATISTICS IO OFF;
88
SET STATISTICS TIME OFF;
99
GO
10-
IF OBJECT_ID('dbo.sp_BlitzTrace') IS NOT NULL
11-
DROP PROCEDURE dbo.sp_BlitzTrace
10+
IF OBJECT_ID('dbo.sp_BlitzTrace') IS NULL
11+
EXEC ('CREATE PROCEDURE dbo.sp_BlitzTrace AS RETURN 0');
1212
GO
13-
CREATE PROCEDURE dbo.sp_BlitzTrace
13+
14+
ALTER PROCEDURE dbo.sp_BlitzTrace
1415
@Debug BIT = 0 , /* 1 prints the statement and won't execute it */
1516
@SessionId INT = NULL ,
1617
@Action VARCHAR(5) = NULL , /* 'start', 'read', 'stop', 'drop'*/
@@ -59,7 +60,7 @@ Known limitations of this version:
5960
Unknown limitations of this version:
6061
- Probably a lot. This is one of our lesser-tested scripts.
6162
62-
Changes in v1.0 - YYYY/MM/DD
63+
Changes in v1.0 - 2016/06/26
6364
- Switched to MIT licensing.
6465
- Added @Help parameter.
6566
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#All Core Blitz Without sp_BlitzQueryStore
2+
Get-ChildItem -Path "C:\Users\$env:username\Documents\GitHub\PublicTools\*" -Include sp_Blitz*.sql -Exclude sp_BlitzQueryStore.sql | ForEach-Object { Get-Content $_.FullName } | Set-Content -Path "C:\Users\$env:username\Documents\GitHub\PublicTools\Install-Core-Blitz-No-Query-Store.sql" -Force
3+
4+
#All Core Blitz With sp_BlitzQueryStore
5+
Get-ChildItem -Path "C:\Users\$env:username\Documents\GitHub\PublicTools\*" -Include sp_Blitz*.sql | ForEach-Object { Get-Content $_.FullName } | Set-Content -Path "C:\Users\$env:username\Documents\GitHub\PublicTools\Install-Core-Blitz-With-Query-Store.sql" -Force
6+
7+
#All Scripts
8+
Get-ChildItem -Path "C:\Users\$env:username\Documents\GitHub\PublicTools\*" -Include sp_*.sql | ForEach-Object { Get-Content $_.FullName } | Set-Content -Path "C:\Users\$env:username\Documents\GitHub\PublicTools\Install-All-Scripts.sql" -Force
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# First Responder Kit Release Process
2+
3+
From http://FirstResponderKit.org
4+
5+
This doc explains how to do a release of the First Responder Kit scripts.
6+
7+
It's for internal use at BrentOzar.com, but other folks might find it useful.
8+
9+
Well, useful is probably the wrong word. More like entertaining. Here we go.
10+
11+
## Preparations
12+
13+
* Create a Milestone to tag issues/PRs as you work on them. In Github, go into Issues, Milestones (button at the top), and add a new milestone named YYYY-MM, like 2017-01.
14+
* As you merge pull requests into the dev branch (or before), tag them with the milestone. This makes it easy to find the related issues when you go to write release notes.
15+
16+
17+
## Finalize and Test the Code
18+
19+
* Make sure all issues in the milestone are closed - click Issues, Milestones, and it'll show the percent complete. If there's any issues you want to bump to the next round, add the next round's milestone and tag the issues with it.
20+
* When enough PRs are in dev, do a round of code testing in 2008-2016 in the cloud lab.
21+
* Merge scripts into three files:
22+
* Runs command in Merge Blitz.ps1
23+
* These get moved to AWS for testing
24+
* Run _TestBed.sql: this has stored proc calls with common parameters. May have to add in new scenarios if new features are added.
25+
* If it passes, bump all the version numbers inside the scripts and re-run the PowerShell commands so combined scripts reflect correct version and date.
26+
* sp_foreachdb @Version and @VersionDate
27+
* sp_BlitzWho @Version and @VersionDate
28+
* sp_BlitzIndex @Version and @VersionDate
29+
* sp_BlitzFirst @VersionDate (no version)
30+
* sp_BlitzCache @Version and @VersionDate
31+
* sp_Blitz @Version and @VersionDate
32+
* sp_DatabaseRestore @Version and @VersionDate
33+
* sp_BlitzBackups @Version and @VersionDate
34+
* sp_BlitzQueryStore @Version and @VersionDate
35+
* sp_AllNightLog @Version and @VersionDate
36+
* sp_AllNightLog_Setup @Version and @VersionDate
37+
38+
## Push to Master
39+
40+
* Push to the master branch from dev. (Make sure you're pushing FROM dev, TO master.)
41+
* Draft a new release. Click Code, Releases, and edit one of the recent releases to get the Markdown syntax. Copy/paste that into a new release, and put the issue numbers for the relevant changes.
42+
* Publish the release pointing at the current master branch code (not dev).
43+
44+
## Announce It
45+
46+
* Copy the FRK scripts into BrentOzar.com's First Responder Kit zip file (Employees/Products/First Responder Kit/FirstResponderKit.zip)
47+
* Copy the FirstResponderKit.zip into Employees/Public.BrentOzar
48+
* Copy the Github release text into a WordPress blog post with the First Responder Kit category. The nice thing about doing the Github release first is that you should be able to copy/paste the Github release page and the HTML should paste smoothly into the WordPress draft window, complete with links to the Github issues. At the end of the post, put a download now link that points to: https://www.brentozar.com/first-aid/
49+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
DECLARE @database_name NVARCHAR(MAX), @backup_path NVARCHAR(MAX), @i INT
2+
3+
SET @database_name = 'ENTER YOUR DATABASE NAME'
4+
SET @backup_path = 'Path to your Ola Backups ROOT FOLDER (see the db name will be attached later)'
5+
SET @i = 0
6+
7+
EXECUTE dbo.DatabaseBackup
8+
@Databases = @database_name,
9+
@Directory = @backup_path,
10+
@BackupType = 'FULL',
11+
@Verify = 'Y',
12+
@Compress = 'Y',
13+
@CheckSum = 'Y',
14+
@CleanupTime = 24
15+
16+
/*Why do I add delays, IDK just wanted to make sure streams do not get crossed */
17+
WAITFOR DELAY '00:00:30'
18+
19+
EXECUTE dbo.DatabaseBackup
20+
@Databases = @database_name,
21+
@Directory = @backup_path,
22+
@BackupType = 'DIFF',
23+
@Verify = 'Y',
24+
@Compress = 'Y',
25+
@CheckSum = 'Y',
26+
@CleanupTime = 24
27+
28+
WAITFOR DELAY '00:00:30'
29+
30+
WHILE (@i <= 10)
31+
BEGIN
32+
SET @i += 1
33+
EXECUTE dbo.DatabaseBackup
34+
@Databases = @database_name,
35+
@Directory = @backup_path,
36+
@BackupType = 'LOG',
37+
@Verify = 'Y',
38+
@Compress = 'Y',
39+
@CheckSum = 'Y',
40+
@CleanupTime = 24
41+
WAITFOR DELAY '00:00:03'
42+
END
43+
44+
DECLARE @cmd NVARCHAR(4000), @BackupPathDiff NVARCHAR(MAX), @PointInTime NVARCHAR(4000), @full_path NVARCHAR(MAX), @diff_path VARCHAR(MAX), @log_path VARCHAR(MAX)
45+
DECLARE @FileList TABLE (BackupFile NVARCHAR(255))
46+
SET @full_path = @backup_path + '\' + @database_name + '\FULL\'
47+
SET @diff_path = @backup_path + '\' + @database_name + '\DIFF\'
48+
SET @log_path = @backup_path + '\' + @database_name + '\LOG\'
49+
50+
-- get list of files
51+
SET @cmd = 'DIR /b "'+ @log_path + '"';
52+
INSERT INTO @FileList (BackupFile)
53+
EXEC master.sys.xp_cmdshell @cmd;
54+
55+
SET @PointInTime = (SELECT TOP 1 * FROM @FileList ORDER BY NEWID())
56+
SET @PointInTime = REPLACE(LEFT(RIGHT(@PointInTime, 19),15), '_', '')
57+
PRINT @full_path
58+
PRINT @diff_path
59+
PRINT @log_path
60+
61+
EXEC dbo.sp_DatabaseRestore
62+
@Database = @database_name,
63+
@BackupPathFull = @full_path,
64+
@BackupPathDiff = @diff_path,
65+
@BackupPathLog = @log_path,
66+
@RestoreDiff = 1,
67+
@ContinueLogs = 0,
68+
@RunRecovery = 1,
69+
@StopAt = @PointInTime,
70+
@Debug = 1;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*Blitz*/
2+
EXEC sp_Blitz @CheckUserDatabaseObjects = 1, @CheckServerInfo = 1
3+
4+
EXEC sp_Blitz @CheckUserDatabaseObjects = 1, @CheckServerInfo = 1, @OutputDatabaseName = 'ChangeMe', @OutputSchemaName = 'dbo', @OutputTableName = 'Blitz'
5+
6+
EXEC sp_Blitz @CheckUserDatabaseObjects = 1, @CheckServerInfo = 1, @Debug = 1
7+
8+
EXEC sp_Blitz @CheckUserDatabaseObjects = 1, @CheckServerInfo = 1, @Debug = 2
9+
10+
/*BlitzFirst*/
11+
EXEC sp_BlitzFirst @Seconds = 5, @ExpertMode = 1
12+
13+
EXEC sp_BlitzFirst @SinceStartup = 1
14+
15+
EXEC sp_BlitzFirst @Seconds = 5, @ExpertMode = 1, @ShowSleepingSPIDs = 1
16+
17+
/*BlitzIndex*/
18+
EXEC sp_BlitzIndex @GetAllDatabases = 1, @Mode = 4
19+
20+
EXEC sp_BlitzIndex @DatabaseName = 'StackOverflow', @Mode = 4
21+
22+
EXEC sp_BlitzIndex @DatabaseName = 'ChangeMe', @Mode = 4
23+
24+
EXEC sp_BlitzIndex @DatabaseName = 'StackOverflow', @Mode = 4, @SkipPartitions = 0, @SkipStatistics = 0
25+
26+
EXEC sp_BlitzIndex @DatabaseName = 'ChangeMe', @Mode = 4, @SkipPartitions = 0, @SkipStatistics = 0
27+
28+
EXEC sp_BlitzIndex @GetAllDatabases = 1, @Mode = 1
29+
30+
EXEC sp_BlitzIndex @GetAllDatabases = 1, @Mode = 2
31+
32+
EXEC sp_BlitzIndex @GetAllDatabases = 1, @Mode = 3
33+
34+
35+
/*BlitzCache*/
36+
EXEC sp_BlitzCache @SortOrder = 'all'
37+
38+
EXEC sp_BlitzCache @SortOrder = 'all avg'
39+
40+
EXEC sp_BlitzCache @MinimumExecutionCount = 10
41+
42+
EXEC sp_BlitzCache @OutputDatabaseName = 'ChangeMe', @OutputSchemaName = 'dbo', @OutputTableName = 'BlitzCache'
43+
44+
/*BlitzBackups*/
45+
EXEC sp_BlitzBackups @HoursBack = 1000000
46+
47+
/*sp_AllNightLog_Setup*/
48+
EXEC master.dbo.sp_AllNightLog_Setup @RPOSeconds = 30, @RTOSeconds = 30, @BackupPath = 'D:\Backup', @RestorePath = 'D:\Backup', @RunSetup = 1

0 commit comments

Comments
 (0)