Skip to content

Instantly share code, notes, and snippets.

🕵
Figuring it out

Eitan Blumin EitanBlumin

🕵
Figuring it out
Block or report user

Report or block EitanBlumin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@EitanBlumin
EitanBlumin / Get Top Query Plans with Warnings from Cache.sql
Created Jan 12, 2020
Get Top Query Plans with Warnings from SQL Plan Cache
View Get Top Query Plans with Warnings from Cache.sql
/***************************************************************************
Get Top Query Plans with Warnings from Cache
--------------------------------------------
Author: Eitan Blumin | https://www.eitanblumin.com
Change Log:
2020-01-12 - First version
****************************************************************************/
DECLARE
@MinimumSubTreeCost FLOAT = 30
@EitanBlumin
EitanBlumin / check_untrusted_check_constraints.sql
Created Jan 9, 2020
Find and check untrusted Check Constraints in all active databases
View check_untrusted_check_constraints.sql
IF OBJECT_ID('tempdb..#tmp') IS NOT NULL DROP TABLE #tmp;
CREATE TABLE #tmp (DBName SYSNAME, SchemaName SYSNAME, TableName SYSNAME, FullTableName AS QUOTENAME(SchemaName) + N'.' + QUOTENAME(TableName), UntrustedObject SYSNAME);
INSERT INTO #tmp(DBName, SchemaName, TableName, UntrustedObject)
EXEC sp_MSforeachdb 'IF EXISTS (SELECT * FROM sys.databases WHERE state_desc = ''ONLINE'' AND name = ''?'' AND DATABASEPROPERTYEX(''?'', ''Updateability'') = ''READ_WRITE'')
BEGIN
USE [?];
SELECT ''?'', OBJECT_SCHEMA_NAME(parent_object_id), OBJECT_NAME(parent_object_id), [name]
FROM [?].sys.check_constraints
WHERE is_not_trusted = 1 AND is_not_for_replication = 0 AND is_disabled = 0;
@EitanBlumin
EitanBlumin / helper_script_for_adding_schemabinding_to_scalar_functions.sql
Last active Jan 16, 2020
Helper T-SQL script for adding SCHEMABINDING on scalar functions (checks in ALL databases on the server)
View helper_script_for_adding_schemabinding_to_scalar_functions.sql
/*
Author: Eitan Blumin | https://www.eitanblumin.com
Description:
Helper T-SQL script for adding SCHEMABINDING on scalar functions (checks in ALL databases on the server)
Instructions:
1. Run the script to detect all scalar functions with disabled SCHEMABINDING, that can potentially have it enabled.
2. Review the 1st resultset for the full list of detected functions.
View Check Index Fragmentation Based on Page Fullness and Fill Factor.sql
/**************************************************************************
Check Index Fragmentation based on Page Fullness and Fill Factor
***************************************************************************
Author: Eitan Blumin | https://www.eitanblumin.com
Version History:
2020-01-07 First version
Description:
This script was inspired by Erik Darling's blog post here:
https://www.erikdarlingdata.com/2019/10/because-your-index-maintenance-script-is-measuring-the-wrong-thing/
@EitanBlumin
EitanBlumin / Generate recommendations for clustered indexes.sql
Last active Jan 7, 2020
Use existing non-clustered index usage stats, and missing index stats, to generate clustered-index recommendations for heap tables
View Generate recommendations for clustered indexes.sql
-------------------------------------------------------
------ Generate Clustered Index Recommendations -------
-------------------------------------------------------
-- Author: Eitan Blumin | https://www.eitanblumin.com
-------------------------------------------------------
-- Change log:
-- ------------
-- 2020-01-07 Added check of database Updateability, and moved around a few columns
-- 2019-12-29 Added checks for IDENTITY columns, and first DATE/TIME columns
-- 2019-12-23 First version
@EitanBlumin
EitanBlumin / compression_savings_estimation_whole_database.sql
Last active Jan 12, 2020
This script performs compression savings estimation check across the ENTIRE database within which it is executed.
View compression_savings_estimation_whole_database.sql
-------------------------------------------------------
-------- Compression Savings Estimation Check ---------
-------------------------------------------------------
-- Author: Eitan Blumin | https://www.eitanblumin.com
-- Create Date: 2019-12-08
-------------------------------------------------------
-- Change Log:
-- -----------
-- 2019-12-09 - added ONLINE rebuild option
-- 2019-12-24 - flipped to traditional ratio calculation; added READ UNCOMMITTED isolation level; added minimum difference thresholds for PAGE vs. ROW considerations
@EitanBlumin
EitanBlumin / zendesk_open_ticket.ps1
Created Aug 22, 2019
Powershell script to open Zendesk support tickets, or add comment to an existing ticket (based on requester and subject). Useful for automatic monitoring and alerting systems.
View zendesk_open_ticket.ps1
param
(
[string] $Subject = "This is a test ticket from Powershell",
[string] $Body = "This is test description",
[string] $RequesterEmail = "dbmonitor@madeiradata.com",
[string] $SourceServer = "SqlDev2016",
[string] $SQLVersion = "2016",
[string] $SQLEdition = "Developer",
[string] $Priority = "low",
[string] $StartDate = "2018-04-17 23:30",
@EitanBlumin
EitanBlumin / Find Invalid Records by Check Constraint.sql
Last active Jul 31, 2019
Find the records which cause your not trusted check constraint to fail
View Find Invalid Records by Check Constraint.sql
/************** Find Invalid Records ***************
Author: Eitan Blumin
****************************************************/
DECLARE
@Constraint SYSNAME = 'CK_Name'
, @PrintOnly BIT = 0
DECLARE
@TableID INT,
@CheckDefinition NVARCHAR(MAX),
View Parse Vulnerability Assessment Results File into HTML.sql
/******************************************************************
Parse SQL Vulnerability Assessment Tool Results
***********************************************
Author: Eitan Blumin | https://www.eitanblumin.com
Description:
Use this script to parse a Vulnerability Assessment Tool
results file into a relational structure.
This will output the T-SQL queries used by VAT behind the scenes
and their respective meta-data, as displayed in the VAT.
View trello_cards_to_github_issues.ps1
param (
[Parameter(Mandatory)][string] $GitHubToken,
[Parameter(Mandatory)][string] $GitHubOwner,
[Parameter(Mandatory)][string] $GitHubRepo,
[Parameter(Mandatory)][string] $SourceTrelloJsonFile,
[string[]] $TrelloLists,
[bool] $UpdateExistingIssuesByTitle = $true,
[bool] $AddNonExistingIssues = $true,
[bool] $Logging = $true
)
You can’t perform that action at this time.