Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Kendra Little LitKnd

🏠
Working from home
View GitHub Profile
@LitKnd
LitKnd / !configure-blocked-process-report.sql
Last active April 24, 2023 19:57
Blocked Process Report - Configuring and Tracing - SQL Server
View !configure-blocked-process-report.sql
/***********************************************************************
Copyright 2016, Kendra Little - littlekendra.com
MIT License, http://www.opensource.org/licenses/mit-license.php
***********************************************************************/
/***********************************************************************
FIRST, TELL SQL SERVER TO ISSUE THE BLOCKED PROCESS REPORT
***********************************************************************/
/* Check if there are any pending configuration items before you start */
View Script-out-all-indexes-in-a-database.sql
/*****************************************************************************
MIT License, http://www.opensource.org/licenses/mit-license.php
Contact: help@sqlworkbooks.com
Copyright (c) 2018 SQL Workbooks LLC
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom
@LitKnd
LitKnd / Mmmm_Chocolatey.ps1
Last active November 27, 2022 14:31 — forked from SQLvariant/Mmmm_Chocolatey.ps1
Install SQL / Data Developer Desktop Tools from Chocolatey
View Mmmm_Chocolatey.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install chocolatey -y
choco install sql-server-2017 -y #developer edition
choco install sql-server-management-studio -y
choco install azure-data-studio -y
choco install azuredatastudio-powershell -y
choco install git.install -y
choco install poshgit -y
View Swapping-In-Tables-With-Switch-Partition.sql
/* Note: don't run this all at once. There are prompts to run some queries in another session, etc. */
WHILE @@trancount > 0
ROLLBACK
GO
USE master;
GO
IF DB_ID('lockingtest') IS NOT NULL
@LitKnd
LitKnd / !DDL-Trigger-Sample.sql
Last active January 9, 2022 17:05
SQL Server DDL Trigger for Index Create, Alter, Rename
View !DDL-Trigger-Sample.sql
/***********************************************************************
Copyright 2016, Kendra Little - LittleKendra.com
MIT License, http://www.opensource.org/licenses/mit-license.php
***********************************************************************/
USE WideWorldImporters;
GO
IF (select count(*) from sys.schemas where name='ddl')=0
exec ('CREATE SCHEMA ddl AUTHORIZATION dbo;');
View SQLCompareFilterExcludingUsers.scpf
<xml version="1.0" encoding="utf-8" standalone="yes"?>
<!--
RedGate.SQLCompare.UI
RedGate.SQLCompare.UI
Version:14.5.2.18630-->
<NamedFilter version="1" type="SQLCompareFilter">
<!--This filter can be loaded using the SQL Compare UI or used with a SQL Compare command line session using the /filter switch-->
<FilterName>SQLCompareFilterExcludingUsers</FilterName>
<Filter version="1" type="DifferenceFilter">
<FilterCaseSensitive>False</FilterCaseSensitive>
@LitKnd
LitKnd / top queries by physical reads.sql
Last active April 2, 2021 11:07
Top queries by writes, top queries by physical reads
View top queries by physical reads.sql
SELECT TOP 20
(SELECT CAST(SUBSTRING(st.text, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset
END
- qs.statement_start_offset)/2) + 1) AS NVARCHAR(MAX)) FOR XML PATH(''),TYPE) AS [TSQL],
qs.execution_count AS [#],
qs.total_physical_reads as [physical reads],
CASE WHEN execution_count = 0 THEN 0 ELSE
View Default-sublime-commands
[
{
"caption": "Reg Replace: Format VTT",
"command": "reg_replace",
"args": {"replacements": ["remove_timestamps", "remove_numbered_lines","remove_empty_lines","remove_line_endings","remove_WEBVTT_literal","remove_v_tags"]
}
},
]
View altering views with two different syntaxes.sql
USE master;
GO
SET NOCOUNT ON;
GO
/*******************************************
Set up the database and table
********************************************/
@LitKnd
LitKnd / test.sql
Created October 17, 2020 13:39
i can add a script
View test.sql
select * from sys.databases