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 / 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),
@EitanBlumin
EitanBlumin / Parse Vulnerability Assessment Scan Json File.sql
Last active Jul 21, 2019
Parse JSON scan results file from a SQL Vulnerability Assessment Tool into a relational structure
View Parse Vulnerability Assessment Scan Json File.sql
DECLARE @j NVARCHAR(MAX)
SELECT @j = BulkColumn
FROM OPENROWSET (
BULK 'C:\Temp\vat_example_results_file.json'
, SINGLE_NCLOB) FileName
IF ISJSON(@j) = 1
PRINT N'Imported JSON is valid'
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
)
@EitanBlumin
EitanBlumin / PrintMax Minified Temporary Procedure.sql
Last active Sep 2, 2019
This is a minified version of the PrintMax procedure (originally written by Ben Dill). It's created as a temporary procedure.
View PrintMax Minified Temporary Procedure.sql
IF OBJECT_ID('tempdb..#PrintMax') IS NOT NULL DROP PROC #PrintMax;
GO
CREATE PROCEDURE #PrintMax @str NVARCHAR(MAX)
AS
BEGIN
IF (@str IS NULL) RETURN;
DECLARE @LBindex INT,@len INT;
SET @len = 4000;
WHILE (LEN(@str) > @len) BEGIN
SET @LBindex = CHARINDEX((CHAR(10) + CHAR(13)) COLLATE database_default, REVERSE(LEFT(@str, @len)) COLLATE database_default);
View FilterParseJsonParameters.sql
/*
Fully Parameterized Search Query
--------------------------------
Copyright Eitan Blumin (c) 2018; email: eitan@madeiradata.com
You may use the contents of this SQL script or parts of it, modified or otherwise
for any purpose that you wish (including commercial).
Under the single condition that you include in the script
this comment block unchanged, and the URL to the original source, which is:
http://www.eitanblumin.com/
@EitanBlumin
EitanBlumin / Generate Procedure Unit Test with Auto-Comparison.sql
Last active Jan 16, 2019
Use this script to generate and run a "unit test" for two stored procedures. This script is good as a "sanity check" of sorts, that makes sure the operational effect of two procedures is the same. The script also prints out the duration of each procedure in milliseconds.
View Generate Procedure Unit Test with Auto-Comparison.sql
/**************************************************************************************************/
/* Generate Procedure Unit Test with Automatic Comparison */
/**************************************************************************************************/
-- Author: Eitan Blumin
-- Date: 2018-11-21
-- Description: Use this script to generate and run a "unit test" for two stored procedures.
-- Each procedure is considered to be affecting one or more database tables.
-- The contents of these tables can be compared before and after each unit test,
-- and the results of each of the two stored procedures can be compared.
@EitanBlumin
EitanBlumin / Get Recent SQL Error Log Errors.sql
Created Nov 22, 2018
Coalesces error messages from SQL Error Log into one row per exception
View Get Recent SQL Error Log Errors.sql
DECLARE @MinutesBackToCheck INT = 10;
SET NOCOUNT ON;
DECLARE @start DATETIME;
SET @start=DATEADD(MINUTE,-@MinutesBackToCheck,GETDATE());
DECLARE @errors AS TABLE
(
ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
LogDate DATETIME,
@EitanBlumin
EitanBlumin / Find Orphaned Records By Foreign Key.sql
Last active Dec 17, 2018
Find which records are causing your Foreign Key check to fail
View Find Orphaned Records By Foreign Key.sql
/************** Find Orphaned Records **************
Author: Eitan Blumin
****************************************************/
DECLARE
@ForeignKeyName SYSNAME = 'FK_MyTable_MyOtherTable'
, @PrintOnly BIT = 0
DECLARE
@FKId INT,
@ChildTableID INT,
View Data Driven Alternative Email and File Share.sql
-- Based on script by Jason Selburg
-- https://www.sqlservercentral.com/Forums/Topic279460-150-1.aspx
-- http://www.sqlservercentral.com/scripts/Miscellaneous/31733/
USE ReportServer
GO
IF OBJECT_ID(N'[dbo].[data_driven_subscription]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[data_driven_subscription]
GO
You can’t perform that action at this time.