Você está na página 1de 38

SQL Server Data Tools

Gavin Campbell

Why are
we here

SOFTWARE
Why do we
have
software?

Image courtesy of Computer History Museum

CHANGE

Image: public.resource.org

Image: canticle at en.wikipedia

If it didnt change, it would be called

HARDWARE

Software is easy to change

Deploying software changes


Overwrite the old with
the new
Side-by-side installation
Replace the whole VM
None of these
techniques will work for
our database code.

The database has


memory or state
The state is in the
data
Any changes we make
need to preserve the
data, and hence the
state

Database Changes

How can we
make database
changes without
destroying our
data?

DEMO

MANAGING DATABASE CHANGE WITH


SCHEMA MOVEMENT SCRIPTS

SCHEMA MOVEMENT SCRIPTS


Need to be IDEMPOTENT
A function f : D -> D is idempotent if f (f x) = f x for
all x in D.
i.e. repeated applications have the same effect as
one

Free Online Dictionary of


Computing
http://foldoc.org/

SCHEMA MOVEMENT SCRIPTS


Can grow to be very long
Some changes can be complicated to
implement
Can lead to run-time (i.e deploy-time) errors
Emphasise the non-functional over the
functional
Force us to use a declarative language in an
imperative manner

Declarative vs Imperative
Programming
Describe what we want

Describe how to do it

Ask the customer their


Let me get an
name
Upside down, Half Put two shots of
tripleLevel
venti nonpeppermint
syrup in3the cup
Msgcaf,
8623,
16, State
1, Line
fat no whip
Put three shots of half-caf
in theinternal
cup
white
Thepeppermint
query processor
ranespresso
out of
.
resources
could not
produce a query
chocolateand
mocha
plan.
Extra Hot

Declarative vs Imperative
Programming

Look Familiar?

SSDT
A better mousetrap?
Development
Experience
Deployment Tools

WHATS IN A NAME?
Visual Studio 2005 Team Edition for Database
Professionals (aka DataDude)
Visual Studio Team System 2008 Database Edition
Visual Studio Team System 2008 Database Edition
GDR
Visual Studio 2010 Database Projects (aka DBPro)
Project Juneau
SQL Server Data Tools

INSTALLING SSDT?

What does this button do?

Installing SSDT?

Installing SSDT?

FUN FACTS ABOUT SSDT

Download from microsoft.com


Updated several times per year
Available for VS2010, VS2012
Installs Visual Studio shell if none available
No separate download for VS2013, but
available in express SKUs
As of now, SQL Server 2014CTP2 only
supported in the VS2012 version

SSDT
A better mousetrap?
Development
Experience
Deployment Tools

CONNECTED DEVELOPMENT
Using the SQL Server Object Explorer in Visual
Studio, developers can now create, edit and
browse database objects located in either an onpremise database server, such as SQL Server
2008 or Microsoft SQL Server 2012, or offpremise in SQL Azure.

http://msdn.microsoft.com/en-us/library/hh272679%28v=vs.103%29.aspx

DEMO

CONNECTED DEVELOPMENT

CONNECTED
DEVELOPMENT

Why not try it


out back at the
office?

Project based Development


Brings Visual Studio features to T-SQL
development
Source Control Integration
Refactoring
Navigation
Debugging
Static Analysis
Unit Testing*

Software Development
Code

Deploy

Build

Test

Database Development?

http://www.flickr.com/photos/aiwells/4675530418

Project based Development

For developers with limited or no access to a


live (production) database, SSDT provides an
improved development experience over the
existing Visual Studio database projects.

http://msdn.microsoft.com/en-us/library/hh272702%28v=vs.103%29.aspx

DEMO

PROJECT BASED DEVELOPMENT

SSDT
A better mousetrap?
Development
Experience
Deployment Tools

Data Tier Applications


Introduced in SQL Server 2008 R2
Support added to SQL Server 2008 SP2 (but not in
SSMS!)
Special Visual Studio project type
Original Version only supported side-by-side
upgrades
In place upgrade supported in SQL Server 2008
R2 SP1 and VS2010 SP1
.dacpac file extension
This is the build output from SSDT

Data Tier Applications


Deploy from Visual Studio ???
Deploy from SSMS using the Wizard
Deploy from the command line using
sqlpackage.exe

All of these use the DacFX API

SQLPackage.exe
Extract: Creates a database snapshot (.dacpac)
file from a live SQL Server or Windows Azure SQL
Database.
Publish: Incrementally updates a database
schema to match the schema of a source .dacpac
file. If the database does not exist on the server,
the publish operation will create it. Otherwise, an
existing database will be updated.
Script: Creates a Transact-SQL incremental
update script that updates the schema of a target
to match the schema of a source.

SQLPackage.exe
Provides greater flexibility than the SSMS
Wizard
Can be automated using PowerShell, .bat files,
Continuous Integration tools, etc.

SUMMARY

Easier Development
with SSDT

Easier Deployment
with DacFX

More information
SSDT Team Blog
http://blogs.msdn.com/b/ssdt/
Jamie Thomson
http://sqlblog.com/blogs/jamie_thomson/arc
hive/tags/SSDT/default.aspx
Technitrain London 3-4 March 2014

THANK YOU

Você também pode gostar