Skip to content

Instantly share code, notes, and snippets.

View EitanBlumin's full-sized avatar
🕵️‍♂️
Figuring it out

Eitan Blumin EitanBlumin

🕵️‍♂️
Figuring it out
View GitHub Profile
@EitanBlumin
EitanBlumin / Asynchronous Ledger Demo.sql
Created July 12, 2021 20:46
Asynchronous Ledger Demo
/*
Asynchronous Ledger Demo
========================
Author: Eitan Blumin | https://eitanblumin.com | https://madeiradata.com
Date: 2021-07-03
Description:
This script demonstrates a use case of a high-throughput table
which serves as a "hot-spot" for inserts and updates and queries.
This causes performance problems due to long lock chains, possible deadlocks,
and sometimes even worker thread starvation.
@EitanBlumin
EitanBlumin / Extended Properties as Database Global Variables.sql
Created June 14, 2021 07:29
Use Extended Properties as Database Global Variables
/*
================================================
Extended Properties as Database Global Variables
================================================
Author: Eitan Blumin | https://madeiradata.com | https://eitanblumin.com
Date: 2021-06-04
Description:
Use this sample script as a template or starting point
for when you want to utilize extended properties
to save and retrieve values as if using "global" variables
@EitanBlumin
EitanBlumin / sp_help_revlogin2.sql
Last active March 16, 2023 14:15
sp_help_revlogin2 is a simpler alternative to sp_help_revlogin
IF OBJECT_ID('tempdb..#sp_help_revlogin2') IS NOT NULL DROP PROCEDURE #sp_help_revlogin2
GO
/*********************************************************************************************
sp_help_revlogin2 V1.2
Eitan Blumin
https://eitanblumin.com | https://madeiradata.com
https://gist.github.com/EitanBlumin/1f19b0b3f59a9220641c559653b90f15
https://github.com/MadeiraData/MadeiraToolbox/blob/master/Utility%20Scripts/sp_help_revlogin2.sql
https://eitanblumin.com/2021/05/11/t-sql-tuesday-138-sp_help_revlogin-is-dead-long-live-sp_help_revlogin2/
@EitanBlumin
EitanBlumin / sp_DBPermissions.sql
Last active August 20, 2021 17:51 — forked from sqlstudent144/sp_DBPermissions.sql
sp_DBPermissions
IF OBJECT_ID('tempdb..#sp_DBPermissions') IS NOT NULL DROP PROCEDURE #sp_DBPermissions
GO
/*********************************************************************************************
sp_DBPermissions V6.1
Kenneth Fisher
http://www.sqlstudies.com
https://github.com/sqlstudent144/SQL-Server-Scripts/blob/master/sp_DBPermissions.sql
This stored procedure returns 3 data sets. The first dataset is the list of database
IF OBJECT_ID('#sp_SrvPermissions') IS NOT NULL DROP PROCEDURE #sp_SrvPermissions
GO
/*********************************************************************************************
sp_SrvPermissions V6.1
Kenneth Fisher
http://www.sqlstudies.com
https://github.com/sqlstudent144/SQL-Server-Scripts/blob/master/sp_SrvPermissions.sql
This stored procedure returns 3 data sets. The first dataset is the list of server
@EitanBlumin
EitanBlumin / simplest_alternative_to_sp_MSforeachdb.sql
Last active August 29, 2022 10:05
The simplest possible alternative to sp_MSforeachdb
/*
Author: Eitan Blumin | https://eitanblumin.com | https://madeiradata.com
Description:
This is the simplest possible alternative to sp_MSforeachdb which is not too great.
Instructions:
1. Replace the contents of the @Command variable with the command you want to run INSIDE each database.
2. Replace the contents of the @Parameters variable with the parameters you want the command to receive.
3. Add parameters as needed, given @p1 as an example.
4. Change the database filter predicates in the cursor declaration, as needed.
@EitanBlumin
EitanBlumin / Configure load balancer IP and name for a domain-independent AG.ps1
Created January 20, 2021 07:22
Script to configure load balancer listener IP and name for a domain-independent Availability Group in a Windows Workgroup
<#
.SYNOPSIS
Script to configure load balancer listener IP and name for a domain-independent Availability Group in a Windows Workgroup
Author: Eitan Blumin
Date: 2021-01-20
.DESCRIPTION
This script is adapted from the scripts provided in the following resources:
############## Setup ##############
$AGName = ''
$AGPrimary = ''
$AGSecondary = ''
# This allows you to process just a subset of databases using the name (wildcards are possible)
$DBNamePattern = 'AdventureW*'
$TargetFolder = 'K:\Data\'
@EitanBlumin
EitanBlumin / SentryOne_CPU_Utilization_Stats_for_all_Sql_Server_Targets.sql
Created January 11, 2021 19:59
Script to run in the SentryOne database to get CPU utilization min/max/avg/6σ for all targets
USE SentryOne
GO
DECLARE
@SiteName NVARCHAR(1000) = NULL
,@SqlServerName NVARCHAR(1000) = NULL
,@End_date DATETIME = NULL
,@Start_date DATETIME = NULL
,@CounterID SMALLINT = 1858 -- CPU %
,@DefaultDaysBack INT = 90
@EitanBlumin
EitanBlumin / Foreign_Key_Hierarchy_Tree.sql
Created January 7, 2021 16:07
T-SQL script to retrieve the hierarchy tree for a given table, based on foreign key references.
/*
Retrieve Foreign Key Hierarchy Tree
===================================
Author: Eitan Blumin | https://eitanblumin.com | https://madeiradata.com
Date: 2021-01-07
Description:
Retrieve the hierarchy tree for a given table,
based on foreign key references.
Use this script to map out your entity relational structure,
see which foreign keys are dependent on a given table,