This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
@CurrDB SYSNAME = DB_NAME() | |
,@WhatIf BIT = 1 | |
DECLARE @CMD NVARCHAR(MAX), @SnapshotName SYSNAME; | |
SET @SnapshotName = @CurrDB + '_snapshot_' + CONVERT(nvarchar, GETDATE(), 112) + REPLACE(CONVERT(nvarchar, GETDATE(), 114),':',''); | |
SELECT @CMD = ISNULL(@CMD + N', | |
', N'') + N'(NAME = ' + QUOTENAME(name) + N' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Author: Eitan Blumin (t: @EitanBlumin | b: eitanblumin.com) | |
-- Date: 2020-05-31 | |
-- Last Update: 2020-07-15 | |
-- Description: Collect T-SQL Error Events using an Extended Events Buffer | |
-- The script automatically detects whether you're in an Azure SQL DB, or a regular SQL Server instance. | |
SET NOCOUNT ON; | |
DECLARE | |
@SourceLinkedServer SYSNAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Eitan Blumin | @EitanBlumin, https://www.eitanblumin.com | |
Create Date: 2016-06-03 | |
Last Update: 2020-05-19 | |
Description: | |
This procedure creates a partitioned view on top of identically-named tables that exist in multiple databases. | |
Parameters: | |
@DBNamePattern - Database name pattern to use for filtering the relevant databases |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Author: Eitan Blumin (t: @EitanBlumin | b: eitanblumin.com) | |
-- Date: 2020-05-31 | |
-- Last Update: 2021-04-22 | |
-- Description: Collect T-SQL Events using an Extended Events Buffer | |
SET NOCOUNT ON; | |
DECLARE | |
@SourceLinkedServer SYSNAME | |
, @MinimumDurationMilliSeconds BIGINT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Author: Eitan Blumin (t: @EitanBlumin | b: eitanblumin.com) | |
-- Description: Get a single row per each high severity error from the SQL Server Error Log | |
DECLARE | |
@SampleTime DATETIME = DATEADD(MINUTE,-30,SYSDATETIME()) | |
, @MinimumSeverity INT = 17 | |
, @MaximumSeverity INT = 25; | |
IF OBJECT_ID(N'tempdb..#errors') IS NOT NULL | |
DROP TABLE #errors; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE EVENT SESSION [TrackFailedLogins] ON SERVER | |
ADD EVENT sqlserver.error_reported( | |
ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.nt_username,sqlserver.database_id,sqlserver.session_id) | |
WHERE (([severity]=(20) OR [severity]=(14) OR [severity]=(16)) | |
AND ([error_number]=(18056) | |
OR [error_number]=(17892) | |
OR [error_number]=(18061) | |
OR [error_number]=(18452) | |
OR [error_number]=(11248) | |
OR [error_number]=(17806) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<opml version="1.0"> | |
<head> | |
<title>Bert's mostly SQL subscriptions in feedly Cloud</title> | |
</head> | |
<body> | |
<outline text="Marketing" title="Marketing"> | |
<outline type="rss" text="Signal v. Noise" title="Signal v. Noise" xmlUrl="https://signalvnoise.com/posts.rss" htmlUrl="https://m.signalvnoise.com"/> | |
<outline type="rss" text="Austin Kleon" title="Austin Kleon" xmlUrl="http://feeds2.feedburner.com/AustinKleon" htmlUrl="https://austinkleon.com"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Eitan Blumin | https://eitanblumin.com | https://madeiradata.com | |
Date Created: 2018-01-02 | |
Last Update: 2023-06-18 | |
Description: | |
Fix All Orphaned Users Within Current Database, or all databases in the instance. | |
Handles 3 possible use-cases: | |
1. Login with same name as user exists - generate ALTER LOGIN to map the user to the login. | |
2. Login with a different name but the same sid exists - generate ALTER LOGIN to map the user to the login. | |
3. Login SID is identifiable but login doesn't exist in SQL - generate CREATE LOGIN FROM WINDOWS to create a Windows authentication login. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first: mkdir user && cd user && cp /path/to/get_gists.py . | |
# python3 get_gists.py user | |
import requests | |
import sys | |
from subprocess import call | |
user = sys.argv[1] | |
r = requests.get('https://api.github.com/users/{0}/gists'.format(user)) |
NewerOlder