SQL in Version Control using SQL Server Database Projects

Get Your SQL
into
Version Control
USING MICROSOFT SQL SERVER DATABASE PROJECTS
Floyd Hilton
@fhilton
Boston Code Camp 23 - Thanks to our Sponsors!
Gold
Bronze
In-Kind Donations
Background
Why put SQL into Version Control?
Lower Risk, Increased Quality
•Keeps history
•Documentation – Tie to issue tracker
•Makes processes repeatable
•Group changes (by feature)
•Continuous Integration and Deployment
•Portability
Two Version Control Processes for SQL
1. Transformation
2. State
Transformation
Incremental changes to the database are saved and then can be run
in order to gain the desired database state
V0.0.1
0001
Database Create
Script
0002
Add Table
0003
Add Procedure
0004
Add Lookup Data
V0.0.2
State 1 State 2
Actual state is not saved, only how to get there
Basic Transformation Process
Custom Tool
V0.1.0
SQL Management Studio
Transformation Tools
•DbUp
•https://www.nuget.org/packages/dbup/
•Flyway
•http://flywaydb.org/
•Nmigrations
•https://github.com/sklose/NMigrations
•roundhouse
•https://github.com/chucknorris/roundhouse
State
The full state of the database is stored for every version
State is saved, and tools are used to transform a
database from one state to another
V0.0.2
Schema
in source control
V0.0.1
Schema
in source control
V0.0.1
Database
Tool compares state
ofcurrent database
to state of schema
in version control
V0.0.2
Database
Transformation
Script or other
Method
Developers
Make
Changes
V0.0.3
Schema
in source control
Developers
Make
Changes
State Tools/Methods
•Manual
•Manually script schema objects and store in source
control
•Entity Framework Migrations
•Redgate SQL Source Control
•SQL Server Database Project
Which to Choose?
TRANSFORMATIONS
When to use
◦ Starting from scratch
◦ Simple model used for a single system
◦ Small team
◦ When a state tool is not available
STATE
When to use
◦ Existing, complex data models
◦ Multiple, interconnected databases
◦ Databases that are used by many systems
◦ Large Team
What is an SQL Database Project?
It is a Visual Studio Project specifically for storing database schema and
information.
What is a Visual Studio Project?
◦ "Projects are used in a solution to logically manage, build, and debug the items that make up
your application. The output of a project is usually an executable program (.exe), a dynamic-
link library (.dll) file or a module, among others.“
◦ For a Database Project, the output is a DACPAC (Data-Tier Application Package)
What is a Solution?
◦ "Solutions contain items that you need in order to create your application. A solution
includes one or more projects, plus files and metadata that help define the solution
as a whole."
Demonstration – SQL Database Project
Resources
Enrico Campidoglio
◦ NDC talk on Continuous Delivery for SQL
◦ http://www.ndcvideos.com/#/app/video/2531
◦ Features DbUP (https://www.nuget.org/packages/dbup/)
◦ .NETROCKS discussion on Continuous Delivery for SQL
◦ http://www.dotnetrocks.com/default.aspx?showNum=1079
Deborah Kurata
◦ Pluralsight video – Visual Studio Data Tools for Developers
◦ http://www.pluralsight.com/courses/visual-studio-data-tools-developers
1 of 14

Recommended

New features of sql server 2005 by
New features of sql server 2005New features of sql server 2005
New features of sql server 2005Govind Raj
3.3K views27 slides
MS Sql Server: Getting Started With Sql Server 2008 by
MS Sql Server: Getting Started With Sql Server 2008MS Sql Server: Getting Started With Sql Server 2008
MS Sql Server: Getting Started With Sql Server 2008DataminingTools Inc
1.2K views12 slides
Serial sql2008 by
Serial sql2008Serial sql2008
Serial sql2008Pedro Bermeo Tarimo
135 views1 slide
A brief introduction to SQLite PPT by
A brief introduction to SQLite PPTA brief introduction to SQLite PPT
A brief introduction to SQLite PPTJavaTpoint
635 views5 slides
SQLite - Overview by
SQLite - OverviewSQLite - Overview
SQLite - OverviewEmanuele Bartolesi
9.8K views17 slides
Sql2008 (1) by
Sql2008 (1)Sql2008 (1)
Sql2008 (1)YanivGupta
528 views10 slides

More Related Content

What's hot

Configuring sql server - SQL Saturday, Athens Oct 2014 by
Configuring sql server - SQL Saturday, Athens Oct 2014Configuring sql server - SQL Saturday, Athens Oct 2014
Configuring sql server - SQL Saturday, Athens Oct 2014Antonios Chatzipavlis
1.4K views38 slides
Troubleshooting sql server by
Troubleshooting sql serverTroubleshooting sql server
Troubleshooting sql serverAntonios Chatzipavlis
1.6K views40 slides
Sql server 2014 online operations by
Sql server 2014 online operationsSql server 2014 online operations
Sql server 2014 online operationsAntonios Chatzipavlis
691 views22 slides
Mysql by
MysqlMysql
MysqlRaghu nath
146 views11 slides
Pre and post tips to installing sql server correctly by
Pre and post tips to installing sql server correctlyPre and post tips to installing sql server correctly
Pre and post tips to installing sql server correctlyAntonios Chatzipavlis
1.4K views46 slides
SQL Server 2012 High Availability with AlwaysOn Availability Groups by
SQL Server 2012 High Availability with AlwaysOn Availability GroupsSQL Server 2012 High Availability with AlwaysOn Availability Groups
SQL Server 2012 High Availability with AlwaysOn Availability GroupsEdwin M Sarmiento
2.4K views26 slides

What's hot(20)

Configuring sql server - SQL Saturday, Athens Oct 2014 by Antonios Chatzipavlis
Configuring sql server - SQL Saturday, Athens Oct 2014Configuring sql server - SQL Saturday, Athens Oct 2014
Configuring sql server - SQL Saturday, Athens Oct 2014
SQL Server 2012 High Availability with AlwaysOn Availability Groups by Edwin M Sarmiento
SQL Server 2012 High Availability with AlwaysOn Availability GroupsSQL Server 2012 High Availability with AlwaysOn Availability Groups
SQL Server 2012 High Availability with AlwaysOn Availability Groups
Edwin M Sarmiento2.4K views
Introducing Microsoft SQL Server 2012 by Intergen
Introducing Microsoft SQL Server 2012Introducing Microsoft SQL Server 2012
Introducing Microsoft SQL Server 2012
Intergen8.1K views
Sql Server 2008 Enhancements by kobico10
Sql Server 2008 EnhancementsSql Server 2008 Enhancements
Sql Server 2008 Enhancements
kobico101.8K views
HPE NonStop SQL WebDBS - Introduction by Frans Jongma
HPE NonStop SQL WebDBS - IntroductionHPE NonStop SQL WebDBS - Introduction
HPE NonStop SQL WebDBS - Introduction
Frans Jongma150 views
Mirroring in SQL Server 2012 R2 by Mahesh Dahal
Mirroring in SQL Server 2012 R2Mirroring in SQL Server 2012 R2
Mirroring in SQL Server 2012 R2
Mahesh Dahal2.3K views
Introduction of ssis by deepakk073
Introduction of ssisIntroduction of ssis
Introduction of ssis
deepakk07310.1K views
Database mirroring setup by K Singh
Database mirroring setupDatabase mirroring setup
Database mirroring setup
K Singh6.6K views
Alwayson AG enhancements by Harsh Chawla
Alwayson AG enhancementsAlwayson AG enhancements
Alwayson AG enhancements
Harsh Chawla1.1K views
BI Publisher Data model design document by adivasoft
BI Publisher Data model design documentBI Publisher Data model design document
BI Publisher Data model design document
adivasoft9.1K views
Writing simple web services in java using eclipse editor by Santosh Kumar Kar
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editor
Santosh Kumar Kar40.8K views
OBIEE11g Multi User Development - MUD by adivasoft
OBIEE11g  Multi User Development - MUDOBIEE11g  Multi User Development - MUD
OBIEE11g Multi User Development - MUD
adivasoft2K views
SQLite3 by cltru
SQLite3SQLite3
SQLite3
cltru1.6K views
Database Mirror for the exceptional DBA – David Izahk by sqlserver.co.il
Database Mirror for the exceptional DBA – David IzahkDatabase Mirror for the exceptional DBA – David Izahk
Database Mirror for the exceptional DBA – David Izahk
sqlserver.co.il3.2K views

Similar to SQL in Version Control using SQL Server Database Projects

Liquibase få kontroll på dina databasförändringar by
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringarSqueed
3.7K views37 slides
Delivering Changes for Applications and Databases by
Delivering Changes for Applications and DatabasesDelivering Changes for Applications and Databases
Delivering Changes for Applications and DatabasesMiguel Alho
8.8K views35 slides
Database CI/CD Pipeline by
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipelinemuhammadhashir57
314 views27 slides
Delivering changes for applications and databases by
Delivering changes for applications and databasesDelivering changes for applications and databases
Delivering changes for applications and databasesEduardo Piairo
773 views36 slides
DMann-SQLDeveloper4Reporting by
DMann-SQLDeveloper4ReportingDMann-SQLDeveloper4Reporting
DMann-SQLDeveloper4ReportingDavid Mann
307 views58 slides
Plantilla oracle by
Plantilla oraclePlantilla oracle
Plantilla oracleUriel Barrales Garrido
315 views45 slides

Similar to SQL in Version Control using SQL Server Database Projects(20)

Liquibase få kontroll på dina databasförändringar by Squeed
Liquibase   få kontroll på dina databasförändringarLiquibase   få kontroll på dina databasförändringar
Liquibase få kontroll på dina databasförändringar
Squeed3.7K views
Delivering Changes for Applications and Databases by Miguel Alho
Delivering Changes for Applications and DatabasesDelivering Changes for Applications and Databases
Delivering Changes for Applications and Databases
Miguel Alho8.8K views
Delivering changes for applications and databases by Eduardo Piairo
Delivering changes for applications and databasesDelivering changes for applications and databases
Delivering changes for applications and databases
Eduardo Piairo773 views
DMann-SQLDeveloper4Reporting by David Mann
DMann-SQLDeveloper4ReportingDMann-SQLDeveloper4Reporting
DMann-SQLDeveloper4Reporting
David Mann307 views
Continuous Integration for Oracle Database Development by Vladimir Bakhov
Continuous Integration for Oracle Database DevelopmentContinuous Integration for Oracle Database Development
Continuous Integration for Oracle Database Development
Vladimir Bakhov4.4K views
Oracle plsql code refactoring - from anonymous block to stored procedure by Carlos Oliveira
Oracle plsql code refactoring - from anonymous block to stored procedureOracle plsql code refactoring - from anonymous block to stored procedure
Oracle plsql code refactoring - from anonymous block to stored procedure
Carlos Oliveira1.3K views
KoprowskiT_SQLSat419_WADBforBeginners by Tobias Koprowski
KoprowskiT_SQLSat419_WADBforBeginnersKoprowskiT_SQLSat419_WADBforBeginners
KoprowskiT_SQLSat419_WADBforBeginners
Tobias Koprowski635 views
Continuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia by Dr. John Tunnicliffe
Continuous Integration and the Data Warehouse - PASS SQL Saturday SloveniaContinuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
Continuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
Continuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia by Dr. John Tunnicliffe
Continuous Integration and the Data Warehouse - PASS SQL Saturday SloveniaContinuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
Continuous Integration and the Data Warehouse - PASS SQL Saturday Slovenia
What to Expect From Oracle database 19c by Maria Colgan
What to Expect From Oracle database 19cWhat to Expect From Oracle database 19c
What to Expect From Oracle database 19c
Maria Colgan11.9K views
Workshop: Delivering chnages for applications and databases by Eduardo Piairo
Workshop: Delivering chnages for applications and databasesWorkshop: Delivering chnages for applications and databases
Workshop: Delivering chnages for applications and databases
Eduardo Piairo49 views
Sql data base by Ali Jafar
Sql data baseSql data base
Sql data base
Ali Jafar77 views
Database CI Demo Using Sql Server by Umesh Kumar
Database CI  Demo Using Sql ServerDatabase CI  Demo Using Sql Server
Database CI Demo Using Sql Server
Umesh Kumar167 views

Recently uploaded

Navigating container technology for enhanced security by Niklas Saari by
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas SaariMetosin Oy
14 views34 slides
Agile 101 by
Agile 101Agile 101
Agile 101John Valentino
7 views20 slides
AI and Ml presentation .pptx by
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptxFayazAli87
11 views15 slides
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptxanimuscrm
14 views19 slides
Myths and Facts About Hospice Care: Busting Common Misconceptions by
Myths and Facts About Hospice Care: Busting Common MisconceptionsMyths and Facts About Hospice Care: Busting Common Misconceptions
Myths and Facts About Hospice Care: Busting Common MisconceptionsCare Coordinations
5 views1 slide
Software evolution understanding: Automatic extraction of software identifier... by
Software evolution understanding: Automatic extraction of software identifier...Software evolution understanding: Automatic extraction of software identifier...
Software evolution understanding: Automatic extraction of software identifier...Ra'Fat Al-Msie'deen
9 views33 slides

Recently uploaded(20)

Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy14 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8711 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm14 views
Myths and Facts About Hospice Care: Busting Common Misconceptions by Care Coordinations
Myths and Facts About Hospice Care: Busting Common MisconceptionsMyths and Facts About Hospice Care: Busting Common Misconceptions
Myths and Facts About Hospice Care: Busting Common Misconceptions
Software evolution understanding: Automatic extraction of software identifier... by Ra'Fat Al-Msie'deen
Software evolution understanding: Automatic extraction of software identifier...Software evolution understanding: Automatic extraction of software identifier...
Software evolution understanding: Automatic extraction of software identifier...
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs by Deltares
DSD-INT 2023 The Danube Hazardous Substances Model - KovacsDSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
Deltares8 views
DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut... by Deltares
DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut...DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut...
DSD-INT 2023 Machine learning in hydraulic engineering - Exploring unseen fut...
Deltares7 views
Headless JS UG Presentation.pptx by Jack Spektor
Headless JS UG Presentation.pptxHeadless JS UG Presentation.pptx
Headless JS UG Presentation.pptx
Jack Spektor7 views
Copilot Prompting Toolkit_All Resources.pdf by Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana8 views
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares17 views
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik5 views
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h... by Deltares
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
DSD-INT 2023 Exploring flash flood hazard reduction in arid regions using a h...
Deltares5 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski10 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
Quality Engineer: A Day in the Life by John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino6 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta6 views

SQL in Version Control using SQL Server Database Projects

  • 1. Get Your SQL into Version Control USING MICROSOFT SQL SERVER DATABASE PROJECTS Floyd Hilton @fhilton
  • 2. Boston Code Camp 23 - Thanks to our Sponsors! Gold Bronze In-Kind Donations
  • 4. Why put SQL into Version Control? Lower Risk, Increased Quality •Keeps history •Documentation – Tie to issue tracker •Makes processes repeatable •Group changes (by feature) •Continuous Integration and Deployment •Portability
  • 5. Two Version Control Processes for SQL 1. Transformation 2. State
  • 6. Transformation Incremental changes to the database are saved and then can be run in order to gain the desired database state V0.0.1 0001 Database Create Script 0002 Add Table 0003 Add Procedure 0004 Add Lookup Data V0.0.2 State 1 State 2 Actual state is not saved, only how to get there
  • 7. Basic Transformation Process Custom Tool V0.1.0 SQL Management Studio
  • 9. State The full state of the database is stored for every version State is saved, and tools are used to transform a database from one state to another V0.0.2 Schema in source control V0.0.1 Schema in source control V0.0.1 Database Tool compares state ofcurrent database to state of schema in version control V0.0.2 Database Transformation Script or other Method Developers Make Changes V0.0.3 Schema in source control Developers Make Changes
  • 10. State Tools/Methods •Manual •Manually script schema objects and store in source control •Entity Framework Migrations •Redgate SQL Source Control •SQL Server Database Project
  • 11. Which to Choose? TRANSFORMATIONS When to use ◦ Starting from scratch ◦ Simple model used for a single system ◦ Small team ◦ When a state tool is not available STATE When to use ◦ Existing, complex data models ◦ Multiple, interconnected databases ◦ Databases that are used by many systems ◦ Large Team
  • 12. What is an SQL Database Project? It is a Visual Studio Project specifically for storing database schema and information. What is a Visual Studio Project? ◦ "Projects are used in a solution to logically manage, build, and debug the items that make up your application. The output of a project is usually an executable program (.exe), a dynamic- link library (.dll) file or a module, among others.“ ◦ For a Database Project, the output is a DACPAC (Data-Tier Application Package) What is a Solution? ◦ "Solutions contain items that you need in order to create your application. A solution includes one or more projects, plus files and metadata that help define the solution as a whole."
  • 13. Demonstration – SQL Database Project
  • 14. Resources Enrico Campidoglio ◦ NDC talk on Continuous Delivery for SQL ◦ http://www.ndcvideos.com/#/app/video/2531 ◦ Features DbUP (https://www.nuget.org/packages/dbup/) ◦ .NETROCKS discussion on Continuous Delivery for SQL ◦ http://www.dotnetrocks.com/default.aspx?showNum=1079 Deborah Kurata ◦ Pluralsight video – Visual Studio Data Tools for Developers ◦ http://www.pluralsight.com/courses/visual-studio-data-tools-developers

Editor's Notes

  1. Initial Questions Who works with applications that use a database Who works with applications that use an SQL Server databbase Who works with creating or updating databases? Who has their db code in version control? Who has used an SQL Database Project? Who has used SQL Server Database Tools in Visual Studio? Who has used other tools like Redgate for comparing schema etc?
  2. Initial Questions Who works with applications that use a database Who works with applications that use an SQL Server databbase Who works with creating or updating databases? Who has their db code in version control? Who has used an SQL Database Project? Who has used SQL Server Database Tools in Visual Studio? Who has used other tools like Redgate for comparing schema etc? Background: Version controls rcs, visual source safe, cvs, subversion, mercurial, git Client with sql database project
  3. Background: Version controls rcs, visual source safe, cvs, subversion, mercurial, git Client with sql database project
  4. Keeps History Ability to get back to a point in time for debugging Know what changed Repeating process