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=$False,Position=1)] | |
[string[]]$servers | |
) | |
if(-not $servers){ | |
$servers = Get-Content servers.txt | |
} |
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
# | |
# Purpose: take the diagnostic queries from Glenn Berry | |
# and generate a Jupyter Notebook to run in Azure Data Studio | |
# | |
# Example usage: | |
# create-diagnostic-notebook.ps1 -diagnosticScriptPath "C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.777\bin\diagnosticquery\SQLServerDiagnosticQueries_2019_201901.sql" -notebookOutputPath "diagnostic-notebook.ipynb" | |
# | |
[CmdletBinding()] | |
Param( | |
[parameter(Mandatory)] |
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
:setvar somevar "somevalue" | |
SELECT '$(somevar)' | |
GO | |
SELECT '$(somevar)' | |
GO |
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 master; | |
GO | |
-- | |
-- CLEANUP | |
-- | |
IF DB_ID('TestMergeRep') IS NOT NULL | |
BEGIN |
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
SELECT MAX(n) | |
FROM ( | |
SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS d, 5 AS e, 6 AS f, 7 AS g, 8 AS h, 9 AS i, 10 AS j | |
) AS sourceData | |
UNPIVOT (n FOR r IN (a,b,c,d,e,f,g,h,i,j)) AS u; |
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
{ | |
"Target": { | |
"ServerName": "(local)\\SQL2014", | |
"SessionName": "deadlocks", | |
"FailOnProcessingError": false, | |
"Responses": [ | |
{ | |
"__type": "EmailResponse", | |
"SMTPServer": "localhost", | |
"Sender": "[email protected]", |
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
-- http://spaghettidba.com/2012/03/23/sql-server-and-custom-date-formats/ | |
-- ============================================= | |
-- Author: Gianluca Sartori - @spaghettidba | |
-- Create date: 2011-10-14 | |
-- Description: Parses a date from its string | |
-- representation, using the supplied | |
-- format string. | |
-- ============================================= | |
CREATE FUNCTION [dbo].[parseDate](@date AS varchar(50), @format_string varchar(50)) | |
RETURNS 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
-- http://spaghettidba.com/2012/03/23/sql-server-and-custom-date-formats/ | |
/* | |
* Returns a data formatted according to the format String. | |
* The format string can contain the following tokens in any order: | |
* | |
* yy --> Year, two digits | |
* YYYY --> Year, four digits | |
* MM --> Month, two digits | |
* m --> Month, one digit | |
* DD --> Day, two digits |
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
-- http://spaghettidba.com/2012/03/23/sql-server-and-custom-date-formats/ | |
-- ============================================= | |
-- Author: Gianluca Sartori - @spaghettidba | |
-- Create date: 2011-10-14 | |
-- Description: Formats a date using the supplied | |
-- format string | |
-- ============================================= | |
CREATE FUNCTION [dbo].[formatDateWithReplace](@date AS datetime, @format_string varchar(50)) | |
RETURNS TABLE | |
AS |
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
-- http://spaghettidba.com/2012/03/23/sql-server-and-custom-date-formats/ | |
-- ============================================= | |
-- Author: Gianluca Sartori - @spaghettidba | |
-- Create date: 2011-10-14 | |
-- Description: Formats a date using the supplied | |
-- format string | |
-- ============================================= | |
CREATE FUNCTION [dbo].[formatDateWithIslands](@date AS datetime, @format_string varchar(50)) | |
RETURNS TABLE | |
AS |