Skip to content

Instantly share code, notes, and snippets.

View LitKnd's full-sized avatar
🏠
Working from home

Kendra Little LitKnd

🏠
Working from home
View GitHub Profile
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
select * from sys.databases
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
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
******************************************/
#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
USE master;
GO
IF DB_ID('SchemaDeployDev') IS NOT NULL
BEGIN
ALTER DATABASE SchemaDeployDev SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE SchemaDeployDev;
END;
CREATE DATABASE QuickTest
GO
USE QuickTest;
GO
CREATE CERTIFICATE SelfSignedCertificate
ENCRYPTION BY PASSWORD = 'helloiamapassword123'
WITH SUBJECT = 'Self Signed Cert Test',
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
use master;
GO
SET NOCOUNT ON;
GO
IF DB_ID('Partitioning') IS NOT NULL
BEGIN
ALTER DATABASE Partitioning SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
USE tempdb;
GO
--reset demo
DROP TABLE IF EXISTS dbo.child,
dbo.parent;
GO
CREATE TABLE dbo.parent
(