Skip to content

Instantly share code, notes, and snippets.

View DarylSmith's full-sized avatar

Daryl Smith DarylSmith

View GitHub Profile
@DarylSmith
DarylSmith / extract.ps1
Created June 29, 2018 12:56
Powershell scripts for extracting data and publishing databases using sqlpackage.exe
#this file extracts database to a dacpac
#path to store the dacpac
$localDbConnStrTemplate ="Data Source=tcp:localhost; Initial Catalog=<db;Integrated Security=True;"
#location to store dacpac
$dacpacTarget="c\testdac.dacpac"
#objects to exclude
$excludeObjectTypes="Aggregates;ApplicationRoles;Assemblies;AsymmetricKeys;BrokerPriorities;Certificates;ColumnEncryptionKeys;ColumnMasterKeys;Contracts;DatabaseRoles;Defaults;ExtendedProperties;ExternalDataSources;ExternalFileFormats;ExternalTables;Filegroups;FileTables;FullTextCatalogs;FullTextStoplists;MessageTypes;PartitionFunctions;PartitionSchemes;Permissions;Queues;RemoteServiceBindings;RoleMembership;Rules;SearchPropertyLists;SecurityPolicies;Sequences;Services;Signatures;SymmetricKeys;UserDefinedTableTypes;ClrUserDefinedTypes;Users;XmlSchemaCollections;Audits;Credentials;CryptographicProviders;DatabaseAuditSpecifications;DatabaseScopedCredentials;Endpoints;ErrorMessages;EventNotifications;EventSessions;LinkedServerLogins;LinkedServers;Logins;Routes;Serv
@DarylSmith
DarylSmith / gist:ff69ee75dc1bb61af44dc9b9d9e00d7a
Created July 2, 2020 21:09
Post-Deployment Script for finding unresolved references in database
/*
--------------------------------------------------------------------------------------
Stored Procedures are late-binding, so they will build even with references to non-existant objects, and will fail at runtime
This script attempts to find any missing references in a database, and can be run as a post deployment script in SSDT to
verify there are no unvalid references after a database has been deployed.
--------------------------------------------------------------------------------------
*/
DECLARE @ResultStr varchar(max)
DECLARE @ResultTable TABLE