🕵️♂️
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 | |
@TopPerDB int = 50, | |
@MinimumRowCount int = 1000, | |
@MinimumUnusedSizeMB int = 1024, | |
@MinimumUnusedSpacePct int = 40, | |
@RebuildIndexOptions varchar(max) = 'ONLINE = ON, SORT_IN_TEMPDB = ON, MAXDOP = 1' -- , RESUMABLE = ON -- adjust as needed | |
SET NOCOUNT, ARITHABORT, XACT_ABORT ON; | |
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; | |
DECLARE @command NVARCHAR(MAX); |
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 FUNCTION dbo.ct_get_last_copied_version | |
( | |
@table_name sysname, | |
@target_identifier sysname = null -- optional parameter if you have multiple sync targets | |
) | |
RETURNS bigint | |
AS | |
BEGIN | |
RETURN ISNULL((SELECT convert(bigint, [value]) | |
FROM sys.extended_properties |
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
-- Function to Retrieve a global variable value | |
-- don't forget to convert to the correct data type | |
CREATE FUNCTION dbo.global_variable(@VariableName sysname) | |
RETURNS sql_variant | |
AS | |
BEGIN | |
RETURN (SELECT [value] | |
FROM sys.extended_properties | |
WHERE major_id = 0 AND minor_id = 0 | |
AND [name] = @VariableName) |
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
/* | |
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. |
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
/* | |
================================================ | |
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 |
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
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/ |
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
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 |
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
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 |
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 | |
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. |
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
<# | |
.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: |