Skip to content

Instantly share code, notes, and snippets.

Kendra Little LitKnd

View GitHub Profile
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
******************************************/
View clone-branch.ps1
#Modified from: https://documentation.red-gate.com/clone/automation/git-hooks
##########################################################################################
############################## clone-branch.ps1 version 0.2 ##############################
##########################################################################################
##################################### Configuration ######################################
#$VerbosePreference = "Continue" # Uncomment this line to enable verbose logging
$InformationPreference = "Continue" # Comment this line to disable information logging
View create n schemas with i tables each.sql
USE master;
GO
IF DB_ID('SchemaDeployDev') IS NOT NULL
BEGIN
ALTER DATABASE SchemaDeployDev SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE SchemaDeployDev;
END;
View altering views with two different syntaxes.sql
USE master;
GO
SET NOCOUNT ON;
GO
/*******************************************
Set up the database and table
********************************************/
View simple certificate and symmetric key.sql
CREATE DATABASE QuickTest
GO
USE QuickTest;
GO
CREATE CERTIFICATE SelfSignedCertificate
ENCRYPTION BY PASSWORD = 'helloiamapassword123'
WITH SUBJECT = 'Self Signed Cert Test',
View dependency queries.sql
SELECT s.name AS [ReferencingSchemaName],
oa.name AS [ReferencingObjectName],
oa.type_desc AS [ReferencingObjectType],
d.referenced_schema_name AS [ReferencedSchemaName],
da.name AS [ReferencedObjectName],
da.type_desc AS [ReferencedObjectType]
FROM sys.sql_expression_dependencies d
LEFT JOIN sys.all_objects oa
View partition-right-dates.sql
use master;
GO
SET NOCOUNT ON;
GO
IF DB_ID('Partitioning') IS NOT NULL
BEGIN
ALTER DATABASE Partitioning SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
@LitKnd
LitKnd / Mmmm_Chocolatey.ps1
Last active Mar 12, 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
View Simple foreign key example.sql
USE tempdb;
GO
--reset demo
DROP TABLE IF EXISTS dbo.child,
dbo.parent;
GO
CREATE TABLE dbo.parent
(
View BuildAndDeploy-SCA-StackOverflow
<#
More examples of PowerShell commands for Continuous Integration:
https://documentation.red-gate.com/sca3/automating-database-changes/continuous-integration
#>
param
(
[string]$project = 'C:\git\StackOverflow\StackOverflow',
[string]$packageVersion = '0.0.001',
[string]$packageID = 'SO',
You can’t perform that action at this time.