Skip to content

Instantly share code, notes, and snippets.

Avatar

Kendra Little LitKnd

View GitHub Profile
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 Apr 2, 2021
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 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
View altering views with two different syntaxes.sql
USE master;
GO
SET NOCOUNT ON;
GO
/*******************************************
Set up the database and table
********************************************/
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 / Mmmm_Chocolatey.ps1
Last active Dec 10, 2020 — 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
@LitKnd
LitKnd / test.sql
Created Oct 17, 2020
i can add a script
View test.sql
select * from sys.databases
View contained database user demo.sql
USE master;
GO
sp_configure 'show advanced options', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
sp_configure 'contained database authentication', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO
View udf example with default constraint.sql
SET QUOTED_IDENTIFIER ON;
GO
SET ANSI_NULLS ON;
GO
/*******************************************
The code for this function contains extra steps, because SQL Server
does not allow you to alter a function if it is referenced by a default constraint
******************************************/