Use this version instead: https://gist.github.com/tcartwright/c27a45a4a211f7cc79466140fb80a56d
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
SET NOCOUNT ON | |
DECLARE @name sysname = N'', | |
@proc_definition NVARCHAR(MAX) = N'', | |
@proc_permissions NVARCHAR(MAX) = N'', | |
@crlf NVARCHAR(4) = CHAR(13) + CHAR(10), | |
@print_only BIT = 1 | |
DECLARE @procs_tbl TABLE ( |
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
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[string] | |
$server, | |
[Parameter(Mandatory=$true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[string] | |
$dbname | |
) |
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
-- REMOVE DATABASE DIAGRAMS OBJECTS FROM DB | |
-- ***WARNING*** ANY EXISTING DIAGRAMS WILL GET DELETED IF YOU RUN THIS ***WARNING*** | |
IF OBJECT_ID('[dbo].[sp_upgraddiagrams]') IS NOT NULL BEGIN | |
DROP PROC [dbo].[sp_upgraddiagrams] | |
END | |
IF OBJECT_ID('[dbo].[sp_helpdiagrams]') IS NOT NULL BEGIN | |
DROP PROC [dbo].[sp_helpdiagrams] | |
END |
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
USE tempdb | |
GO | |
IF OBJECT_ID (N'GetErrorInfo') IS NOT NULL BEGIN | |
DROP PROCEDURE GetErrorInfo | |
END | |
GO | |
CREATE PROCEDURE GetErrorInfo ( |
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
/* | |
Authors: Matthew Naul, Tim Cartwright | |
Purpose: to build a stack trace so that nested stored proces can be followed in the case of an exception. | |
*/ | |
USE tempdb -- change this to the db of your choice. or put it master and make it a system stored proc | |
GO | |
IF OBJECT_ID('dbo.ErrorHandler') IS NULL BEGIN | |
EXEC ('CREATE PROCEDURE dbo.ErrorHandler AS BEGIN SELECT 1; END;'); |
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
-- https://sqlworkbooks.com/2017/06/using-sp_whoisactive-with-temp-tables-to-limit-data-collected/ | |
SET NOCOUNT ON | |
DECLARE @whoisactive_table VARCHAR(4000) = QUOTENAME ('##WhoIsActive_' + CAST(NEWID() as varchar(255))) | |
, @schema VARCHAR(4000) | |
, @dsql NVARCHAR(4000) | |
, @loop_cntr INT = 3 | |
-- build the global temp table | |
EXEC sp_WhoIsActive |
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
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
CREATE OR ALTER PROCEDURE [dbo].[GenerateRandomPwd] ( | |
@password VARCHAR(512) OUTPUT, | |
@length INT = NULL, /* IF passed in then the password will be this exact length */ | |
@lengthMin INT = 35, /* controls the min length of the password if @length is null */ | |
@lengthMax INT = 50, /* controls the max length of the password if @length is null */ |
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
<UserSettings> | |
<ApplicationIdentity version="10.0"/> | |
<ToolsOptions> | |
<ToolsOptionsCategory name="Environment" RegisteredName="Environment"/> | |
</ToolsOptions> | |
<Category name="Environment_Group" RegisteredName="Environment_Group"> | |
<Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package"> | |
<PropertyValue name="Version">2</PropertyValue> | |
<FontsAndColors Version="2.0"> | |
<Categories> |
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
<UserSettings> | |
<ApplicationIdentity version="10.0"/> | |
<ToolsOptions> | |
<ToolsOptionsCategory name="Environment" RegisteredName="Environment"/> | |
</ToolsOptions> | |
<Category name="Environment_Group" RegisteredName="Environment_Group"> | |
<Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package"> | |
<PropertyValue name="Version">2</PropertyValue> | |
<FontsAndColors Version="2.0"> | |
<Categories> |