🕵️♂️
This file contains 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
/* | |
======================================================= | |
Find Top Exec Plans to Optimize | |
======================================================= | |
Author: Eitan Blumin | eitanblumin.com , madeiradata.com | |
Date: 2020-08-12 | |
Description: | |
Use this script to discover execution plans with a good | |
potential for performance optimization. | |
Finds execution plans with warnings and problematic operators. |
This file contains 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
SELECT | |
'ALTER TABLE ' + QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) | |
+ ' DROP CONSTRAINT ' + QUOTENAME(name) | |
FROM sys.foreign_keys | |
WHERE schema_id IN ( SCHEMA_ID('jobs'), SCHEMA_ID('jobs_internal') ) | |
ORDER BY | |
CASE schema_id WHEN SCHEMA_ID('jobs') THEN 1 ELSE 2 END ASC | |
SELECT | |
'DROP VIEW ' + QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(name) |
This file contains 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 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
USE AdventureWorks2008R2 | |
GO | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
IF OBJECT_ID('Purchasing.usp_AT_uPurchaseOrderDetail', 'P') IS NOT NULL | |
DROP PROCEDURE Purchasing.usp_AT_uPurchaseOrderDetail; | |
GO | |
CREATE PROCEDURE Purchasing.usp_AT_uPurchaseOrderDetail |
This file contains 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
/****************************************************************** | |
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 and save in an HTML page. | |
This will output the T-SQL queries used by VAT behind the scenes | |
and their respective meta-data, as displayed in the VAT. |
This file contains 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: 26/06/18 | |
-- Description: | |
-- Compares server level objects and definitions as outputted by the first script (InstancePropertiesGenerateForCompare.sql). | |
-- | |
-- Instructions: | |
-- Run InstancePropertiesGenerateForCompare.sql on each server. Save output to a CSV file. | |
-- Use this script ( InstancePropertiesComparison.sql ) to load the files into a table, and output any differences | |
-- Don't forget to change file paths accordingly. |
This file contains 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
# SQL Database Project Build Configuration | |
trigger: | |
- master | |
pool: | |
vmImage: 'VS2017-Win2016' | |
variables: | |
solution: '**/*.sln' |
This file contains 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
-- Run this in the right SQL Sentry database | |
--USE [SentryOne]; | |
--USE [SQLSentry]; | |
GO | |
IF OBJECT_ID('[dbo].[heartbeat_log]') IS NULL | |
BEGIN | |
CREATE TABLE [dbo].[heartbeat_log]( | |
[servername] [nvarchar](300) CONSTRAINT PK_Heartbeat_Log PRIMARY KEY CLUSTERED WITH(IGNORE_DUP_KEY=ON,DATA_COMPRESSION=PAGE), | |
[heartbeatdate] [datetime] NULL, | |
[ActualHeartbeatDate] [datetime] NULL |
This file contains 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 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
/* | |
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, |