SlideShare uma empresa Scribd logo
1 de 128
SQL SERVER DATA TOOLS
WORKSHOP
Everything you need to know to get started
Slides
  2




               SQLProj.com
                    http://sqlproj.com/index.php/2012/03/sqlbits-2012-
                     ssdt-workshop/
                         Slides:
                                 http://sqlproj.com/wp-content/uploads/2012/03/SSDT-
                                  Workshop-2012-03-29-final.pdf
                         Handout
                                 http://sqlproj.com/wp-content/uploads/2012/03/SSDT-
                                  Workshop-2012-03-29-handout.pdf


Copyright © 2012 Gert Drapers - All Rights Reserved.                                    03/29/2012
3              Introduction
                       gert.drapers@microsoft.com




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Copyright and Disclaimer
  4


               This presentation, including examples are provided for informational
                purposes only, the author makes no warranties, either express or implied.
               Information in this presentation, including samples, URL and other Internet
                Web site references, are subject to change without notice.
               Complying with all applicable copyright laws is the responsibility of the user.
               Without limiting the rights under copyright, no part of this document may be
                reproduced, stored in or introduced into a retrieval system, or transmitted in
                any form or by any means
                (electronic, mechanical, photocopying, recording, or otherwise), or for any
                purpose, without the express written permission of the author.
               The names of actual companies and products mentioned herein may be the
                trademarks of their respective owners.


Copyright © 2012 Gert Drapers - All Rights Reserved.                                       03/29/2012
@DataDude
  5


               1986-1988 IBM Corporation
               1988-1991 Ashton-Tate
               1991-present Microsoft Corp.
                    SDE in the Developer Relations Group (the Netherlands)
                    Senior Development Consultant in MCS (the Netherlands)
                    SDE in Storage Engine (DBCC, Bulk Insert and Convert)
                    Program Manager SQL-DMO and Query Analyzer
                    Product Unit Manager SQL Server Management Tools
                    Software Architect DTS 2005 (now SSIS) and SMO
                    Software Architect MS-DTC, COM+, System.Transactions, WS-AT
                    Software Architect SQL Server Customer Advisory Team (Europe)
                    Principal Group Engineering Manager “Visual Studio Team System Database Edition”
                    Principal Software Architect Azure Active Directory
                    Principal Software Architect Cloud Programmability (SQL)
                    Principal Group Program Manager SQL Server Data Platform




Copyright © 2012 Gert Drapers - All Rights Reserved.                                                    03/29/2012
Agenda
  6



               SQL Server Data Tools Overview
               SQL Server Data Tools Installation
               Data-Tier Application Component (DAC)
               Declarative Database Development
               Connected Development
               Project Based Development
               Application Life Cycle Integration
               Programmatic and Command Line Usage

Copyright © 2012 Gert Drapers - All Rights Reserved.    03/29/2012
7              SQL Server Data Tools Overview




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Database Development Challenges
  8



               Databases are inherently stateful
                 Focus is on ALTER instead of CREATE
                 Dependencies complicate scripts
                 Errors are often found only when scripts are executed
               Synchronizing application and database versions
                    Database development often not integrated in to
                     application life cycle management and processes
               Targeting different SQL Server and SQL Azure
                versions
Copyright © 2012 Gert Drapers - All Rights Reserved.                   03/29/2012
History of the “DataDude” Project
  9


               Project funded April 2005
               Project started July 1st 2005
               Visual Studio 2005 Team System for Database Professionals
               Visual Studio 2008 Team System for Database Professionals
               Re-architected to be declarative model based system
               Visual Studio 2008 Team System for Database Professionals GDR
                R2
               Visual Studio 2010 Team System for Database Professionals
               Transitioned to SQL Server 2009
               SQL Server Data Tools

Copyright © 2012 Gert Drapers - All Rights Reserved.                       03/29/2012
Introducing SQL Server Data Tools
  10




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Connected Development
  11




                                            T-SQL IntelliSense   Drift Detection   Table Designer
          SQL Server
         Object Explorer
                                            T-SQL Debugging                           View Code
                                                                   Schema
                                                                  Comparison
           T-SQL Editor                        View/Edit Data                      Error Information


Copyright © 2012 Gert Drapers - All Rights Reserved.                                              03/29/2012
Project Based Development
  12




                                                               Source Code      Point-in-time
        Go To Definition                  Source Code Based                      Snapshots
                                                                 Control
                                                                              Visualize Schema
       Find All References                    F5 Debugging &     MSBuild         Differences
                                                Testing with     Headless
                                                 LocalDB                      T-SQL Static Code
            Refactoring                                        Command Line
                                                                                  Analysis
                                                                  Tools

Copyright © 2012 Gert Drapers - All Rights Reserved.                                        03/29/2012
Schema Deployment
  13




           Model Based                       SQL Server 2005     DACPAC          Format
                                             SQL Server 2008
                                             SQL Server 2012
            Incremental                        SQL Azure         Connected       Engine
              Schema
            Deployment                     Retargeting Support   SQL Script   API & REDIST


Copyright © 2012 Gert Drapers - All Rights Reserved.                                      03/29/2012
SQL Azure
                                                                    Management Portal



                                                                Import
                                     Publish
                                                                Export
                                     Compare
                                                              Register
                                     Sync
                                                             Unregister
                                                       DAC


   SQL Server Data Tools                                                     SQL Server
                                                                          Management Studio



Copyright © 2012 Gert Drapers - All Rights Reserved.                                   03/29/2012
Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Resources
 16



         SQL Server Data Tools Online Installation
             http://msdn.microsoft.com/data/tools Get It
         Team Blog
             http://blogs.msdn.com/b/ssdt/
         MSDN Forum
             http://social.msdn.microsoft.com/Forums/en-
              US/ssdt/threads
         Articles
                    MSDN Magazine Sept 2011 The "Juneau" Database
Copyright © 2012 GertProject
                     Drapers - All Rights Reserved.                  03/29/2012
SQL Server Data Tools
      17               Installation




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Setup Options
  18




               Install from online Web Platform Installer feed
               Install from SQL Server 2012 DVD
               Install from Visual Studio 11
               Install from offline administrative install



Copyright © 2012 Gert Drapers - All Rights Reserved.          03/29/2012
Supported OS Platforms
  19




               Windows Vista SP2+
               Windows 7 SP1+
               Windows Server 2008 SP+
               Windows Server 2008 R2 SP1+

               Note: this is different then the Visual Studio 2010
                platforms

Copyright © 2012 Gert Drapers - All Rights Reserved.              03/29/2012
Visual Studio Requirements
  20




               Visual Studio 2010 Integrated Shell+
                    SQL-CLR requires Visual Studio 2010 Standard+
               Visual Studio 2010 SP1+
                    Notes:
                       SQL Server 2012 only installs VS 2010 Integrated Shell
                        SP1
                       If you have an existing Visual Studio 2010 installation you
                        must install SP1 yourself (?KB VS2010 SP1 checks)
                       Watch for mixed mode (?KB detecting mixed mode)

Copyright © 2012 Gert Drapers - All Rights Reserved.                              03/29/2012
SSDT Online Acquisition
  21




               Install online via Web Platform Installer (WebPI)
                    SSDT download link for latest bits
                         http://msdn.microsoft.com/en-us/data/hh297027
                    Requires WebPI v3.0 or better to be installed
                         User is prompted on first attempt when not installed or
                          updated
                 Automatically downloads all required new or updated
                  dependencies
                 Invokes SSDTSetup.exe (chained installer)
Copyright © 2012 Gert Drapers - All Rights Reserved.                                03/29/2012
Installing from SQL Server 2012
      DVD
 22




         Install SSDT from SQL Server 2012 DVD image
                    Install VS 2010 SP1 shell if you do not have VS
                     installed
                 If you do have VS 2010 install, user needs to install
                     SP1!
                 DVD puts down a “stub” which will acquire latest
                     SSDT bits online via (WebPI)
                 See http://sqlproj.com/index.php/2011/11/ssdt-setup-
                     from-sql-server-2012/ for detailed step through
Copyright © 2012 Gert Drapers - All Rights Reserved.                    03/29/2012
Creating an Admin Install
  23




               SSDTSetup.exe /layout C:SSDTAdminInstall
                 Pulls down all the latest dependencies from the web
                 Enables generating a local install point which can be
                  shared via a file share or USD drive
                         DMZ or offline installation scenario
               For detailed steps see:
                    http://sqlproj.com/index.php/2011/11/creating-an-
                     administrative-install-for-ssdt

Copyright © 2012 Gert Drapers - All Rights Reserved.                     03/29/2012
SSDTSetup
  24



               SSDTSetup.exe
                    Setup chainer (486 KB)
               SSDTx86SSDT.msi
                    Actual tools (5.75 MB)
               SSDTx86SSDTBuildUtilities.msi
                    MSBuild targets and utilities (970 KB)
               SSDTx86DbSqlPackageProvider.msi
                    Web Deploy Provider (729 KB)

Copyright © 2012 Gert Drapers - All Rights Reserved.          03/29/2012
Setup Dependencies (payload
          directory)
  25


               x86DACFramework.msi                      dotNetFx40_Full_x86_x64.exe
               x86NDP40-KB2468871-v2-x86.exe            NDP40-KB2544514-x86-x64.exe
               x86SharedManagementObjects.msi           x64DACFramework.msi
               x86SQLDom.msi                            x64NDP40-KB2468871-v2-x64.exe
               x86SqlLocalDB.msi                        x64SharedManagementObjects.msi
               x86sqlls.msi                             x64SQLDom.msi
               x86SQLSysClrTypes.msi                    x64SqlLocalDB.msi
               x86SSDTDBSvcExternals.msi                x64sqlls.msi
               x86TSqlLanguageService.msi               x64SQLSysClrTypes.msi
               x86VS10sp1-KB983509.exe                  x64TSqlLanguageService.msi
               x86VSIntShell.exe


Copyright © 2012 Gert Drapers - All Rights Reserved.                                   03/29/2012
Setup Dependencies
  26


               .NET 4.0 CLR runtime
                    dotNetFx40_Full_x86_x64.exe
               .NET 4.0 CLR general update
                    http://support.microsoft.com/kb/2468871
                    NDP40-KB2544514-x86-x64.exe
               Update 4.0.2 for Microsoft .NET Framework 4 – Runtime Update
                    http://support.microsoft.com/kb/2544514
                    NDP40-KB2544514-x86-x64.exe
                    LocalDB support
               Visual Studio 2010 integrated shell
                    VSIntShell.exe
               Visual Studio 2010 SP installer
                    VS10sp1-KB983509.exe
                    http://support.microsoft.com/kb/983509




Copyright © 2012 Gert Drapers - All Rights Reserved.                           03/29/2012
Setup Dependencies…
  27


               SQL Server 2012 Data-Tier Application Framework v3.0
                    DACFramework.msi
               SQL Server 2012 Express LocalDB
                    SqlLocalDB.msi
               SQL Server 2012 Script DOM (parser)
                    SQLDom.msi
               SQL Server 2012 Language Services (compiler and binder)
                    sqlls.msi
               SQL Server 2012 CLR types (geo and hierarchy)
                    SQLSysClrTypes.msi
               SQL Server 2012 Management Objects (SMO)
                    SharedManagementObjects.msi
               SQL Server 2012 Language Services (IntelliSense parser)
                    TSqlLanguageService.msi




Copyright © 2012 Gert Drapers - All Rights Reserved.                      03/29/2012
Headless Installation
  28


               Install the five following components:
                    SQL Server 2012 Data-Tier Application Framework
                     (DACFramework.msi)
                    SQL Server 2012 Transact-SQL ScriptDom (SQLDOM.MSI)
                    SQL Server 2012 Transact-SQL Compiler Service (SQLLS.MSI)
                    Microsoft System CLR Types for Microsoft SQL Server 2012
                     (SQLSysClrTypes.msi)
                    SQL Server Data Tools Build Utilities (SSDTBuildUtilities.msi)
                         NOTE: Need to copy from SSDT Administrative install point
               For detailed description see:
                    http://sqlproj.com/index.php/2012/03/headless-msbuild-support-for-ssdt-
                     sqlproj-projects/
Copyright © 2012 Gert Drapers - All Rights Reserved.                                     03/29/2012
Visual Studio 2012
  29



               SQL Server Database Projects are a standard feature in
                Visual Studio 2012
                    Replaces Visual Studio Database Projects
                    Available in Visual Studio Professional edition and up
                    Integrate shell version will be made available separately as
                     online download
               Visual Studio 2012 RTM will ship with the same functionality
                as the SSDT version shipping with SQL Server 2012 RTM
               Round tripping of projects and project artifacts between
                VS2010 and VS2012 hosted SQL Server Database Projects

Copyright © 2012 Gert Drapers - All Rights Reserved.                                03/29/2012
Setup Log Files
  30


               dir %temp%sql_SSDT_1000*.log
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_0_SQLLS11X64.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_1_SQLDOM11X64.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_2_TSQLLANGSVC11X64.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_3_DACFX11X86.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_4_DACFX11X64.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_5_SQLLOCALDBX64.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_6_SQLCLRTYPES11X86.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_7_SQLCLRTYPES11X64.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_8_SQLSMO11X86.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_9_SQLSMO11X64.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_10_SSDTEXTERNALS10.log“
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_11_SSDTBUILDUTILITIES10.log"
                    "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_12_SSDT10.log"




Copyright © 2012 Gert Drapers - All Rights Reserved.                                                                03/29/2012
31               Declarative Database Development
                       The foundation




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Simple Schema Versioning Example
  32




       -- version 1                                    -- version 2
       CREATE TABLE dbo.Auction                        ALTER TABLE dbo.Auction
       (                                               WITH CHECK ADD CONSTRAINT Au_PK
        id    INT NOT NULL,
        name VARCHAR(25) NOT NULL,                     -- version 3
        start DATETIME NULL,                           ALTER TABLE dbo.Auction
        len   INT NULL                                 WITH CHECK
       )                                               ADD CONSTRAINT Au_SK UNIQUE (name)


       V1        V2           V3                                           Revision History

Copyright © 2012 Gert Drapers - All Rights Reserved.                                     03/29/2012
Imperative
  33



               Imperative scripts hard codes knowledge about:
                    The state of the target system:
                         Presence of objects, dependencies, unbinding, rebinding
                         Required ordering of operations
                    Cumulative changes need to be serialized
                         v1v2v3v4v5 instead of v1v4v5
                    Validating the end-result against expected end-state is
                     hard
                         No easy way to compare expected vs. actual
                    Batching or separating multiple changes
Copyright © 2012 Gert Drapers - All Rights Reserved.                                03/29/2012
Imperative Versioning
 34

        -- version 1 Add table dbo.Auction
        IF OBJECT_ID (N'dbo.Auction', N'U') IS NULL
        BEGIN
        CREATE TABLE dbo.Auction
        (`
              id      INT NOT NULL,
              name VARCHAR(25) NOT NULL,
              start DATETIME NULL,
              len     INT NULL
        )
        END
        -- version 2 Add PK Au_PK
        IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_PK' AND type = 'PK')
        BEGIN
              ALTER TABLE Auction
              WITH CHECK ADD CONSTRAINT Au_PK PRIMARY KEY (id)
        END
        -- version 3 Add UC Au_SK
        IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_SK' AND type = ‘UQ')
        BEGIN
              ALTER TABLE Auction
              WITH CHECK ADD CONSTRAINT Au_SK UNIQUE (name)
        END
Copyright © 2012 Gert Drapers - All Rights Reserved.                                             03/29/2012
Declarative
  35



               Define what you want in the form of a model
               Fill the model using a DSL (domain specific language)
                    T-SQL
               Use the model as the starting point “blueprint” for all
                operations
                    Deployment/publish, start by comparing the current state of the
                     target with the required state (blueprint)
                    Use the resulting difference knowledge to programmatically
                     generate an deployment plan
                    Use plan to create sequence of (SQL) statements required to
                     make the target state become like the blueprint state
Copyright © 2012 Gert Drapers - All Rights Reserved.                               03/29/2012
Declarative Versioning
  36



  -- version 1
  CREATE TABLE dbo.Auction
      -- version 2
  (   CREATE TABLE dbo.Auction
            -- version 3
   id ( INT NOT NULL, dbo.Auction
            CREATE TABLE
   name id ( INT NOT NOT NULL,
          VARCHAR(25) NULL PRIMARY KEY,
   start DATETIME INT NOT NOT NULL,
        name id     NULL,
               VARCHAR(25) NULL PRIMARY KEY,
   len start NULL VARCHAR(25) NOT NULL UNIQUE,
          INTname
               DATETIME NULL,
  )     len start NULL
               INT DATETIME NULL,
      )      len   INT NULL
            )

       V1        V2           V3                       Revision History

Copyright © 2012 Gert Drapers - All Rights Reserved.                03/29/2012
Declarative Schema Deployment
  37
       37



                                Source                                      Target
                                                         Model                                   Reverse
                                Schema                                     Schema
                                                        Compare                                  Engineer
                                 Model                                      Model
                                                         Diff List
                                                          Plan
                                                        Optimizer
                     Additional
                      schema                           Deploy Plan
                      artifacts                         Script
                                                       Generator
                                                        Script                                    Target
                                                       Executor      Incremental target update     DB



Copyright © 2012 Gert Drapers - All Rights Reserved.                                                        03/29/2012
Imperative vs. Declarative
  38




               Manual vs. generated / programmatic
               Point in time vs. always current
               Sequential vs. differential




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Script Fundamentals
  39



               Requirement to be able
                to round trip DSL                                     A
                artifacts                                         S       T
                    Script  Model
                                                                               Script
                         SQL script Parse            T-SQL      Parser
                          Script fragment                                    Fragment

                         Script fragment Script
                          Gen  SQL script              Script
                                                                   Script
                                                                   Gen        T-SQL
               Script fragment is AST                 Fragment

                (Abstract Syntax Tree)
Copyright © 2012 Gert Drapers - All Rights Reserved.                                    03/29/2012
ScriptDom
  40



               SQL Server 2012 managed parser
                    Supports SQL Server 2005+
               Class TSqlXXXParser
                    XXX = [80, 90, 100, 110]
               SQLDom.msi (redist x86/x64)
               Microsoft.SqlServer.TransactSql.ScriptDom.dll
                    C:Program Files (x86)Microsoft SQL Server110SDK
                     AssembliesMicrosoft.SqlServer.TransactSql.ScriptDom.dll
                    GAC

Copyright © 2012 Gert Drapers - All Rights Reserved.                       03/29/2012
Basic ScriptDom loop
  41


                 static void Main(string[] args)
                 {
                      bool initialQuotedIdentifiers = false;
                      TSqlParser parser = new TSql110Parser(initialQuotedIdentifiers);

                         StreamReader sr = new StreamReader(@".test.sql");
                         IList<ParseError> errors;

                         TSqlFragment fragment = parser.Parse(sr, out errors);

                         StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());

                         Sql110ScriptGenerator scriptGen = new Sql110ScriptGenerator();
                         scriptGen.GenerateScript(fragment, sw);
                 }

Copyright © 2012 Gert Drapers - All Rights Reserved.                                         03/29/2012
Reusable Building Blocks
  42




               Model Store
               Model Builder
               Model Serialization
               Model Comparison
               Model Copy


Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Model Store
  43




               Elements                                  Models are stored in
                 Relationships
                                                           ESE database or in-
                                                           memory
                 Properties
                                                          *.dbmdl (Database
               Identifiers                                Model) file extension
               Annotations                                used by local model
                                                           cache.

Copyright © 2012 Gert Drapers - All Rights Reserved.                          03/29/2012
Model Builder
  44




               The schema model is
                populated using
                information from the
                AST representation of
                the SQL parser
               From a model
                element you can
                recreate a script
                fragment (AST)
Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Model Serialization
 45




             Act of serializing and
              de-serializing a
              schema model to and
              from disk or in-
              memory persistence
              model
             Model is serialized as
              XML
                    See digesting a
Copyright © 2012 GertDACPAC
                     Drapers - All Rights Reserved.   03/29/2012
Digesting a .DACPAC
  46




               OPC file
                 Unpack handler associated at file system level
                 Rename .dacpac to .zip to open
                 Compressed
                 Versioned
                         SQL Server 2012 ships with DACPAC version 3.0.0.0
                    http://en.wikipedia.org/wiki/Open_Packaging_Convent
                     ions

Copyright © 2012 Gert Drapers - All Rights Reserved.                          03/29/2012
.DACPAC streams
  47




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Reverse Engineer
  48




               Reverse Engineering
                is a special form of
                model builder, which
                scripts the content of
                a source database in
                the form of SQL
                scripts (model DSL
                input format) to
                construct a model
Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Model Copy / Compare
  49



               Comparing two
                declarative models to
                determine the
                difference
               The comparison engine
                exposes options for
                excluding object
                instances, object
                types, specific options
                on objects and certain
Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Deployment & Schema Compare
  50


       Script                                                                                                  Script
                             Model                                                               Model
                             Builder                                                             Builder
   Fragment                                                                                                   Fragment

                                                       Source                  Target
                            Reverse                                                             Reverse
        DB                                             Schema                 Schema                            DB
                            Engineer                                                            Engineer
                                                        Model                  Model

                                                                  Model
  Schema                    Model                                Compare                         Model       Schema
  Package                  Serializer                                                           Serializer   Package
                                                                  Diff List
                                                                   Plan               Diff
                                                                 Optimizer         Visualizer
                                                                Deploy Plan
                                                                 Script
Copyright © 2012 Gert Drapers - All Rights Reserved.            Generator                                       03/29/2012
Model Based
  51



                 .SQL                                  SqlScript               Schema
                                        Parse           Dom        Interpret            Validate
                Source                                                          Model

               All schema objects are represented inside a model
                    What is in the model is defined by the provider
               To load/hydrate a model instance
                    Parse  SqlCodeDom, based on parsers Abstract Syntax Tree (AST)
                    Interpretation Schema Model
                         Symbol list
                         Object References (hard and soft dependencies)
                    Validation


Copyright © 2012 Gert Drapers - All Rights Reserved.                                           03/29/2012
Component Stack
  52




                                SQL Server Data Tools
                                                                                    TSQL
                      DACFX                                  SMO
                                                                   System.Data.
                                                                     SqlClient
                                                                                  Language
                                                                                   Services
                                                                                                 NetFX
                                                                                                Patches




                                                                                              Visual Studio
           SQLLS              SQLDOM           SQLCLRTypes           LocalDB                  VS2010 SP1,
                                                                                                VS2012


Copyright © 2012 Gert Drapers - All Rights Reserved.                                                   03/29/2012
Data-Tier Application
      53               Component
                       DAC




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
What is a Data-Tier Application
          (dacpac)?
  54



               Data-Tier Application Component (DAC)
                    SQL Server database registered as Data-Tier Application
                     Component
               DAC is a self contained entity of a database used by an
                application
                    Unit of deployment and management
               Authored along side your application code
                    Compiled into a DAC package (DACPAC)
               Extracted for existing databases
                    Database extracted (DACPAC) or exported (BACPAC) into
                     packages
               Package is deployable to SQL Server and SQL Azure
Copyright © 2012 Gert Drapers - All Rights Reserved.                           03/29/2012
DAC Framework v3.0 (DACFX)
  55


               Core SQL Server redist component providing modeling, reverse
                engineering and deployment capabilities

               Managed Public API
                    Exposes verbs for DACPAC and BACPAC package operations
               Command-line tool (SqlPackage.exe)
                    Executable over the managed public API
               DACUnpack.exe
                    Windows file handler for unpacking DACPACs to disk
               DACFX Clients
                    SqlPackage.exe, SSMS, SSDT, SAMP, I&E, VS Web and DB Publishing


Copyright © 2012 Gert Drapers - All Rights Reserved.                                   03/29/2012
DACFX Packages
  56


               .dacpac - Packaged Schema representing the declarative model of the
                database
                    Not SQL, but a declarative Schema Model representation of the database
                    Compiled from source code or Extracted from existing databases
                    Deploy as new database or Incremental Upgrade an existing database
                    Supports all SQL Server Objects and Types


               .bacpac - Packaged Schema and Data representing the state of the
                database
                    Composed of Schema Model with stateful properties and Data Streams
                    Exported from existing databases
                    Imported as a new database or populates an empty database
                    Supports most SQL Server Objects and Types (SQL Azure parity)
Copyright © 2012 Gert Drapers - All Rights Reserved.                                          03/29/2012
DAC Evolution
  57




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
DACFX Supported
          SQL Server Objects and Versions
  58



               SQL Server 2012 DACFX (v3.0) supports the full SQL
                Server Domain
               Supports the following versions:
                    SQL Server 2005
                    SQL Server 2008/R2
                    SQL Server 2012
                    SQL Azure
               DACFX (v3.0) backwards compatibility
                    DACFX 1.0, 1.1, and 2.0

Copyright © 2012 Gert Drapers - All Rights Reserved.            03/29/2012
Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
SQL Server Data Tools
  60


               Developer-focused toolset for authoring, building and publishing DACPACs

               Experiences Enabled
                    Connected Development
                    Project Based Development
                    Application Lifecycle & Tools

               DACPAC verbs
                    Author DACPAC declaratively and build from source
                    Compare DACPAC to project, database, and other DACPACs
                    Import DACPAC into project
                    Publish DACPAC/Project to database


Copyright © 2012 Gert Drapers - All Rights Reserved.                                       03/29/2012
SQL Server Management Studio
  61


               DBA-focused tools for deploying and extracting DACPACs; importing and exporting BACPACs


               Experiences Enabled
                    Administration and Monitoring
                    Connected Development
                    Configuration and Task Wizards
               DACPAC Verbs Supported
                    Deploy Data Tier Application
                    Register/Unregister Data Tier Application
                    Upgrade Data Tier Application
               BACPAC Verbs Supported
                    Import Data Tier Application
                    Export Data Tier Application
                    Migrate Database to SQL Azure




Copyright © 2012 Gert Drapers - All Rights Reserved.                                                      03/29/2012
SQL Azure Management Portal
  62


               Subscriber and Operator oriented toolset for managing SQL Azure databases through DAC Verbs

               Experiences Enabled
                    Connected Development
                    Portal Based Tools
                    Application Lifecycle support
               DACPAC verbs supported
                    Deploy Data Tier Application (create new database from dacpac)
                    Upgrade Data Tier Application (upgrade database to match dacpac)
                    Extract Data Tier Application (create dacpac from existing database)
               BACPAC Verbs supports
                    Export Data Tier Application (export database as bacpac to Windows Azure Blob Storage)
                    Import Data Tier Application (import bacpac as new database from Windows Azure Blob Storage)



Copyright © 2012 Gert Drapers - All Rights Reserved.                                                                03/29/2012
DAC Lifecycle
  63




                 Developer                                      DBA                   DBA/Admin

       Develop (SSDT)                                  Deploy (SSMS)           Manage (SSMS and SAMP)
       • Import Database/                              • Deploy Package        • Export and Extract
         DACPAC                                          • New Databases         Packages
       • Author DAC                                      • Upgrade Databases   • Register Database as DAC
       • Compare and
         Synchronize Source
       • Compile Database
         Project to DACPAC
       • Publish DACPAC

Copyright © 2012 Gert Drapers - All Rights Reserved.                                                  03/29/2012
64               Connected Development
                       Imperative & Declarative
                       Schema Authoring and Deployment




Copyright © 2012 Gert Drapers - All Rights Reserved.     03/29/2012
Connected Development
  65




               SQL Server Object Explorer (SSOX)
                 T-SQL  Editor/Debugger/IntelliSense (New Query)
                 Power-Buffer (New Object/View Code)
                 Table Designer (View Designer)
                 Data Editor (View Data)
                 Execute Procedure/Function

               Schema Compare
Copyright © 2012 Gert Drapers - All Rights Reserved.           03/29/2012
SQL Server Object Explorer (SSOX)
  66


               The SQL Server navigation tool window
                    Modeled after the SSMS Object Explorer
                    Server scoped vs. Server Explorer which is database scoped
                    Launch point for T-SQL Editor, Debugger, Object Execution, Designers, …
               Supports connecting directly to SQL Server
                    SQL Server {2005, 2008, 2008R2, 2012} and SQL Azure
                         Supports connecting directly to a (contained) database
                    Constructs a partial model in the background and under the covers
               Supports:
                    Cascading Drops and Renames
                    Drift detection
                         Automatically updates the tree/source as changes occur on the server
                    SSOX is a DSRef drag source

Copyright © 2012 Gert Drapers - All Rights Reserved.                                             03/29/2012
SSOX Drift Detection
  67




               Controlling Refresh Rate
                 HKEY_CURRENT_USERSoftwareMicrosoftVis
                  ualStudio10.0SQLDBDialogPageMicrosoft.Visu
                  alStudio.Data.Tools.Package.ToolsOptions.Online
                  Editing.OnlineEditingOptionsSettings]
                  "PollingDriftCheckSeconds"="30"
                 Defaults to 30. If set to <= 0 will be infinite (3
                  days). Cannot be less than 30.

Copyright © 2012 Gert Drapers - All Rights Reserved.             03/29/2012
T-SQL Editor/Debugger/IntelliSense
  68



               T-SQL IntelliSense                        Other Options:
                    SQL Server 2005+ incl. SQL               Actual Execution Plan
                     Azure                                    SQLCMD mode
               Result to Grid | Text | File                  Client Statistics
               Execution modes                               Code snippets
                    Parse                                Reusable debug script
                    Estimated Execution Plan              generation
                    Execute                              Keyboard shortcut mapping
                    Execute with debugger                 alignment
                                                              Out-of-band delivery of SSMS
Copyright © 2012 Gert Drapers - All Rights Reserved.           profile                   03/29/2012
T-SQL Editor Keyboard Mapping
  69



                   Commands                   SSMS Keyboard Compatibility Settings   SQL Server Development Settings
                   Execute                    CTRL+E / ALT+X / CTRL+SHIFT+E          CTRL+SHIFT+E
                   Execute w/Debugger         ALT+F5                                 ALT+F5
                   Cancel Query
                   Execution                  ALT+BREAK                              ALT+BREAK
                   Include Actual
                   Execution Plan             CTRL+M                                 CTRL+D, A
                   Display Estimated
                   Execution Plan             CTRL+L                                 CTRL+D, E
                   Results As Grid            CTRL+D                                 CTRL+D, G
                   Results As Text            CTRL+T                                 CTRL+D, T
                   Results As File            CTRL+SHIFT+F                           CTRL+D, F
                   Show/Hide Results          CTRL+R                                 CTRL+D, R
                   New File                   CTRL+N                                 None defined
                 http://blogs.msdn.com/b/ssdt/archive/2012/03/07/using-ssms-keyboard-mappings-in-ssdt.aspx
Copyright © 2012 Gert Drapers - All Rights Reserved.                                                                   03/29/2012
T-SQL Editor/Debugger/IntelliSense
  70




               Toolbar consistencyInclude SSMS
                          Display
                                    with
                                            Estimated    Actual     SQLCMD
                      Parse
                                            Execution   Execution    Mode
                                              Plan        Plan




Copyright © 2012 Gert Drapers - All Rights Reserved.                         03/29/2012
T-SQL Editor/Debugger/IntelliSense
  71




               Context menu consistency improvement




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Power-Buffer/Table Designer
  72


               Declarative deferred online schema management
                    Brings “project-oriented” features to online / connected development
                    Live errors and warnings as changes are made against code
                    “Project-oriented” validation during editing

               Table designer
                    Code-behind designer
                    Works on top of Power-Buffer (partial model) or project model
                    Strives to be the same experience online as experienced in the project system

               Coordinated execution of buffers against the same target
                    Diff scripts by default are transactional
                     (ToolsOptionsSQL Server ToolsOnline EditingInclude transactional scripts)


Copyright © 2012 Gert Drapers - All Rights Reserved.                                                 03/29/2012
Data Editor
  73




               View and Edit Data via grid editor
               Copy-Paste support
               Generate as INSERT to file or query window




Copyright © 2012 Gert Drapers - All Rights Reserved.         03/29/2012
Execute Procedure/Function
  74




               Dialog based input for parameter collection
                 Generates                      SQL script for execution/debugging




Copyright © 2012 Gert Drapers - All Rights Reserved.                                  03/29/2012
Schema Compare
  75




               Performs a model comparison between:
                 Databases
                 Projects
                 DACPAC                      files (snapshots, build outputs, extracts)
               Supports:
                 Refactoring
                           log
                 SQLCMD variables

Copyright © 2012 Gert Drapers - All Rights Reserved.                                  03/29/2012
Schema Compare
  76




               Behavioral comparison options
               Object type filtering
                 Applicationscoped
                 Non-application scoped




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Schema Compare
  77

                                                Next and Previous move between top-         Simpler set of columns are aligned around the central
                                                level objects, no longer expand the tree.   action column echoes alignment of schemas above



 Group-by Action is the                                                                                                                         Same
 default                                                                                                                                        column order
                                                                                                                                                is used for all
                                                                                                                                                groupings;
                                                                                                                                                cleaner and
 Schema no longer
                                                                                                                                                easier to
 used as a parent for
                                                                                                                                                parse
 top-level objects; only
                                                                                                                                                regardless of
 shown when changed
                                                                                                                                                grouping




 Improved script diff’
 algorithm for tables
 emphasizes columns
 as unit of change.
 Gives much improved
 alignment. Also
 improved look



Copyright © 2012 Gert Drapers - All Rights Reserved.                                                                                                03/29/2012
Schema Compare
  78




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
79               Project Based Development
                       Offline and Isolated
                       Schema Authoring and Deployment




Copyright © 2012 Gert Drapers - All Rights Reserved.     03/29/2012
Project Based Development
  80




               Database Projects
               Database References
               Publishing Projects




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Database Projects
  81



               Creating and Importing
               Additional Language Services
               Isolated Sandbox
               Database Schema Snapshots
               Build Time Validation
               T-SQL Static Code Analysis
               SQL-CLR Support
               Pre & Post Deployment Scripts

Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Creating and Importing
  82


               Single project template
                    VSDB note:
                         No distinction between server or user projects
                         Server projects are projects with target database set to master
               Import from:
                    Database
                    DACPAC
                    SQL Script (multi-file import enabled)
                    Selective import by using Schema Compare
               “Create New Project” from SSOX
                    Inherits version from source database


Copyright © 2012 Gert Drapers - All Rights Reserved.                                        03/29/2012
Project Files
  83


               *.sqlproj
                    MSBuild based project file
               *.sqlproj.user
                    MSBuild based user specific settings (merged-in)
               *.dbmdl
                    <project>.dbmdl is the schema model cache file
                         Will get rebuild when deleted
                         Should not get checked-in, in to source code control (SSC)
                    ESE (Extensible Storage Engine) database file
                         http://technet.microsoft.com/en-us/library/bb310772.aspx
                         Managed interface http://managedesent.codeplex.com/

Copyright © 2012 Gert Drapers - All Rights Reserved.                                   03/29/2012
Folder Structure
  84




               Options on import:
                 None

                 Schema

                 Object
                       type
                 SchemaObject type




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Project Directory Guidelines
  85


               The projects directory root path is the only thing that matters!
                    This is determined based on the location of the .sqlproj file
                    You have to stay underneath this location
                    All file paths are relative to this location
               The initial project structure is a good starting point and works for all
                objects
               You can change the complete directory structure
                    But if you remove the default layout we do not know where the
                     automatically place objects when using “Add New Item” or when using
                     Import Script
                         Result: Objects will be placed in the project root location
                    Advice: Extend the base structure, do not replace
Copyright © 2012 Gert Drapers - All Rights Reserved.                                    03/29/2012
Project Directory Guidelines…
  86



               Be aware of MAX_PATH (260 characters)
                    All relative file locations must fit within MAX_PATH
                    Your SCC environment might have problems when you
                     exceed MAX_PATH
                    Choose your project root location wisely
               Filenames encoding:
                    objectname.sql or schema.objectname.sql
                    <sysname>.<sysname>.sql
                    sysname = max 128 characters

Copyright © 2012 Gert Drapers - All Rights Reserved.                        03/29/2012
Project Directory Guidelines…
  87




               Be aware of empty directories when using Source
                Code Control
                    Placement of new objects when using Add New Item
                     or when using Schema Compare end up in the project
                     root when location is not present
               Do not host more then one table inside script file
                    Table designer will not see additional tables inside
                     script
Copyright © 2012 Gert Drapers - All Rights Reserved.                        03/29/2012
Include files
  88



               Include files
                    Add Existing Item As Link
                       <Build Include="..Northwind2dboTablesCategories.sql">
                         <Link>Categories.sql</Link>
                       </Build>

                    Use to share files between projects
               VSDB note:
                    SQL Server Database Projects do not support partial
                     projects
Copyright © 2012 Gert Drapers - All Rights Reserved.                               03/29/2012
Additional Language Services
  89



               Projects enable additional language services
                    Go To Definition
                    Find All References
                    Refactoring
                         Rename (sp_rename)
                         Move to Schema (ALTER SCHEMA schema_name TRANSFER)
                         Wildcard Expansion
                         Fully Quality Name
               Invoked from Editor, Table Designer and SQL Server Object
                Explorer for project based schema objects

Copyright © 2012 Gert Drapers - All Rights Reserved.                           03/29/2012
Isolated Sandbox
  90




               F5 – Run by default configure to use the LocalDB
                instance associated with the project
                    Data Source=(localdb)<project name>;Initial
                     Catalog=<project name>;Integrated
                     Security=True;Pooling=False;Connect Timeout=30
               To retarget to a different SQL Server version
                and/or shared SQL Server change:
                    Project propertiesDebugTarget Connection String

Copyright © 2012 Gert Drapers - All Rights Reserved.                     03/29/2012
SQL Server 2012 Express LocalDB
  91


               Simplify embedded usage of SQL Server
                    Simple installation
                    Zero-admin database
               Same programming surface as User Instances of SQL Express
                    The same sqlservr.exe as in service-based SQL Server with the same language and features
                    Connection through the same client-side APIs, using a new connection string option
               SQL Server programming symmetry
               Installation similar to .NET Framework model
                    One set of installed binaries (per major version), no global configuration, no constantly-running service
               Activation model similar to RANU (Access, SQL Compact, …)
                    The application connects to a database file, SQL activates automatically
                    No service: SQL process starts in the context of current user
               Default connection string
                    (localdb)v11.0
               http://msdn.microsoft.com/en-us/library/hh510202(v=SQL.110).aspx


Copyright © 2012 Gert Drapers - All Rights Reserved.                                                                             03/29/2012
LocalDB Setup
  92


               Packaged in a small single MSI
                    SqlLocalDB.msi x32 (27.5 MB)
                    SqlLocalDB.msi x64 (32.7 MB)
               Single registry key to check if LocalDB Runtime is installed
                                                                        C:
                  [HKLMSOFTWAREMicrosoftMicrosoft SQL Server Local     Program Files
                  DBInstalled Versions11.0]                               Microsoft SQL Server
                                                                              110
               Silent installation                                             LocalDB
                                                                                   sqlservr.exe
                  SQLLocalDB.msi /Quiet /IAcceptLicenseTerms                       […]
                                                                              120
               Side-by-side versions                                           LocalDB
                                                                                   sqlservr.exe
                                                                                   […]

Copyright © 2012 Gert Drapers - All Rights Reserved.                                     03/29/2012
Each user has their LocalDB instance (process)
                                                                                                            Created and started lazily when needed


           LocalDB Process Model                                                                         All SQL Server process infrastructure is hidden
                                                                                                            Including System Databases (master & friends)
  93




       Same Machine, Same User Context
                                                       new SqlConnection(
                                                       “Server=(LoacalDB)v11.0;
                                                       AttachDBFile=|DataDirectory|App1DB.mdf“);


                    App1                                                                                                        App1
                                                                                                                                 DB
       User Code – Visible
       Infrastructure – Hidden
                                                                                                                temp
                                                                                            model

                                                                                                    master
       C:Program Files                                                                                 C:UsersjohnsmithAppData
       Microsoft SQL Server                                                          msdb
                                                                                                         LocalMicrosoftMicrosoft SQL
       110LocalDBBinnsqlservr.exe
                                                                                                         ServerLocalDBv11.0...
Copyright © 2012 Gert Drapers - All Rights Reserved.                                                                                            03/29/2012
Database Schema Snapshots
  94



               Point-in-time representation of schema model
                 Model must be “error-free” state
                 Produces same file format (*.dacpac) as build or
                  extract
               To be used for:
                 Versioning
                 Comparison
                 Sharing schema definitions or changes
                …

Copyright © 2012 Gert Drapers - All Rights Reserved.                 03/29/2012
Build Time Validation
  95



               Build validates the complete model
                    Platform specific validation
                         Example – Enforces clustered index requirement on tables in SQL
                          Azure
                    Integration with Compiler Services
                         Engine-level build-time validation without schema deployment
                         Leverages CDB and SQL2012 engine capabilities
               Pre & Post Deployment scripts
                    Build validates syntactical correctness of pre- and post-
                     deployment scripts using the SQLCMD variables
               Build serializes the model in to model.xml stream inside
                .dacpac file
Copyright © 2012 Gert Drapers - All Rights Reserved.                                        03/29/2012
Build Actions
  96


               Build - This script will be interpreted as T-SQL (or an XML Schema in the
                case of XML Schema Collections) and reflected in the T-SQL Model
               Compile - C# or VB (depending on your project properties) to be deployed
                as a SQLCLR assembly
               None - Use this for any loose artifacts (like text files)
               PreDeploy - The pre deployment master script (there can only be one)
               PostDeploy - The post deployment master script (there can only be one)
               RefactorLog - This is a refactor log which notifies the DaxFx deployment
                engine that particular changes should be interpreted as refactoring
                operations and not drop/adds
               Build Extension Configuration - Reserved for future use, for this is
                interpreted as None

Copyright © 2012 Gert Drapers - All Rights Reserved.                                   03/29/2012
Build Output
  97




               Build output path
                 .sqldebug

                 .sqlrelease

               Intermediate output path
                 .objdebug

                 .objrelease


Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
T-SQL Static Code Analysis
  98




               Rule set
               Suppression
                 Filelevel
                 Project level

               MSBuild support


Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
SQL-CLR Support
  99




               Supports:
                 Embedded                        C# or VB.NET code artifacts
                       Deployed                as SQL-CLR objects
                 Binary    assembly deployment and SQL-CLR
                     object association
                       Example:
                                 CREATE TYPE [ClrSchema].[IPv4]
                                  EXTERNAL NAME [IPAssembly].[IPv4];

Copyright © 2012 Gert Drapers - All Rights Reserved.                            03/29/2012
Pre & Post Deployment Scripts
 100



               Can be used for any “arbitrary” SQL actions that you need to
                perform “before” and “after” deployment of the schema
                objects
               The pre deployment block comes after the generic database
                context validation block
               The post deployment block comes after the schema objects
                block
               Pre and post deployment scripts must be idempotent
                    They are “executed” each deployment!
                    http://blogs.msdn.com/gertd/archive/2007/01/25/idempotent-
                     scripts-required.aspx
Copyright © 2012 Gert Drapers - All Rights Reserved.                              03/29/2012
Pre & Post Deployment Scripts…
 101



               The pre or post deployment master files are
                identified in the .sqlproj file through special item
                type tags
                    <PreDeploy Include="ScriptsPre-
                     DeploymentScript.PreDeployment.sql">
                        <SubType>Code</SubType>
                     </PreDeploy>
                     <PostDeploy Include="ScriptsPost-
                     DeploymentScript.PostDeployment.sql">
                        <SubType>Code</SubType>
                     </PostDeploy>
Copyright © 2012 Gert Drapers - All Rights Reserved.                   03/29/2012
Pre & Post Deployment Scripts…
 102



               Include files using :r (SQLCMD include)
               File paths of includes are relative to the pre or post
                deployment master file
               Included files must exist, even when empty
                    Not existing include fail will cause an error state at build time
               Include files have to be tagged “NotInBuild”
                    <NotInBuild Include="ScriptsPost-
                     DeploymentDatabaseObjectOptions.sql">
                        <SubType>NotInBuild</SubType>
                     </NotInBuild>

Copyright © 2012 Gert Drapers - All Rights Reserved.                                     03/29/2012
SQLCMD Variables
 103


               Restrictions
               Substitution order (vs. sqlcmd.exe)
               MSBuild mapping
               SQLCMD variables can be used in:
                    Pre & post deployment scripts
                    Within schema objects variable have to be placed between square brackets or
                     double or single quotes
                         [$(var)] or “$(var)” or „$(var)‟
                    !!!Cannot be used as object identifiers!!!
               Variables are defined and store in ???
                    Configuration dependent ???


Copyright © 2012 Gert Drapers - All Rights Reserved.                                          03/29/2012
Database References
 104




               master and msdb references
               3-4 part names
               Composition




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Database References
 105




               Literal vs. variable references
                 Literal             can be used for 2 and 3-part names only
               Self vs. 3- vs. 4-part name
                 Same   database
                 Different database, same server
                 Different database, different server

               Build order and circular references
Copyright © 2012 Gert Drapers - All Rights Reserved.                            03/29/2012
Database References
 106




               File based references (*.dacpac)
                 Create    directory underneath the project root to
                     store dacpac files, to ensure it is a relative path
                     and transports correctly with the project in source
                     code control
                       Example:                Reference*.dacpac
                 Make               sure to point to a v3.0 .dacpac

Copyright © 2012 Gert Drapers - All Rights Reserved.                   03/29/2012
master and msdb references
 107


               master references can be explicit or implicit
                    master.dbo.<object> or master.sys.<object>
                         <Annotation Type="AliasedToDbo" />
                    Global namespace
                         <Annotation Type="GloballyScoped" />
                    Example:
                         select * from master.dbo.sysprocesses
                          select * from master.sys.sysprocesses
                          select * from sysprocesses
               msdb references are always explicit 3-part references
                    Example:
                         select job_id from msdb.dbo.sysjobs

Copyright © 2012 Gert Drapers - All Rights Reserved.                    03/29/2012
3- & 4-part Names
 108



               3-part name usage:
                    SELECT * FROM
                     [LiteralDBRef].[Schema1].[Table1]
                    SELECT *
                     FROM [$(DBRef)].[Schema1].[Table1]
               4-part name usage:
                    SELECT *
                     FROM [$(ServerRef)].[$(DBRef)].[Schema1].[Table1]
                    SELECT *
                     FROM [$(ServerRef)].[LiteralDBRef].[Schema1].[Table1]

Copyright © 2012 Gert Drapers - All Rights Reserved.                         03/29/2012
Composition
 109



               Composite Projects
                    Schema distributed across multiple
                     database projects
                         Enable division of schema along security
                          or organizational boundaries
                    Published as “one” logical database
                         Referenced objects brought into parent
                          model on build
                         Controlled by “Include Composite Objects”
                          advanced publish option
                         Removes the need for separate
                          deployment of composing projects

Copyright © 2012 Gert Drapers - All Rights Reserved.                  03/29/2012
Publishing Projects
 110




               Multi-targeting
               Deployment Options




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
Multi-Targeting
 111




               Target version aware:
                 SQL Server 2005
                 SQL Server 2008 & SQL Server 2008 R2
                 SQL Server 2012
                 SQL Azure

               Publish
                 Direct,              via SQL script, or DACPAC snapshots

Copyright © 2012 Gert Drapers - All Rights Reserved.                         03/29/2012
Publishing Profiles
 112




         MSBuild fragment for sharing deployment
          

         settings
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <IncludeCompositeObjects>True</IncludeCompositeObjects>
     <TargetDatabaseName>DinnerNow</TargetDatabaseName>
     <DeployScriptFileName>TestSqlProj.sql</DeployScriptFileName>
     <TargetConnectionString>Data Source=gmf4vyn24r.database.windows.net;
          User ID=gertd@gmf4vyn24r;Pooling=False</TargetConnectionString>
     <ProfileVersionNumber>1</ProfileVersionNumber>
   </PropertyGroup>
 </Project>



Copyright © 2012 Gert Drapers - All Rights Reserved.                               03/29/2012
Deployment Options
 113



               Options to influence
                deployment behavior
                 Ignore*
                 Deployment validation
                  options
                       Do not alter Change Data
                        Capture objects
                       Do not ALTER replicated
                        objects
                       Verify deployment
                                 Deploy without a safety-net
Copyright © 2012 Gert Drapers - All Rights Reserved.            03/29/2012
114               Application Life Cycle Integration
                       Team development and central build
                         services




Copyright © 2012 Gert Drapers - All Rights Reserved.        03/29/2012
Application Life Cycle Integration
 115




              MSBuild Support
              Source Code Control Integration
              Build Server Integration




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
MSBuild Support
 116



               MSBuild tasks for:
                    Build
                    Publish
                         Note: requires using a publishing profile
                    T-SQL Static Code Analysis
               SSDTBuildUtilities.msi
                    Redist for MSBuild specific components
                    http://sqlproj.com/index.php/2012/03/headless-msbuild-
                     support-for-ssdt-sqlproj-projects/

Copyright © 2012 Gert Drapers - All Rights Reserved.                          03/29/2012
Source Code Control Support
 117




               SQL Server Data Tools works with all Visual
                Studio Source Code Control (SCC) providers
                 SQL   Server Database Projects fully integrate with
                     SCC, no need to do anything special




Copyright © 2012 Gert Drapers - All Rights Reserved.               03/29/2012
Build Server Integration
 118




               Building
                 Use            MSBuild
               Deploying/publishing
                 Use MSBuild (requires publish profile)
                 Use SqlPackage.exe
                       Suggestion:                    use answer file, override from command
                          line
Copyright © 2012 Gert Drapers - All Rights Reserved.                                        03/29/2012
Programmatic and Command
     119               Line




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
SqlPackage.exe
 120




               Part of DACFramework.msi (redist)
               Location:
                    %ProgramFiles(x86)%Microsoft SQL
                     Server110DACbin
               /Action:
                    {Extract|DeployReport|DriftReport|Publish|Script}
               Supports response file @file
                    Command line override settings in response file
Copyright © 2012 Gert Drapers - All Rights Reserved.                     03/29/2012
DacUnpack.exe
 121




               C:Program Files (x86)Microsoft SQL
                Server110DACbin
               Explorer file handler for unpacking .DACPAC
                 Note:             not a command line tools




Copyright © 2012 Gert Drapers - All Rights Reserved.           03/29/2012
MSBuild Tasks
 122




               MSBuild /t:Build | Publish | StaticCodeAnalysis
               Target file
                 C:Program     Files
                     (x86)MSBuildMicrosoftVisualStudiov10.0SSDT
                     Microsoft.Data.Tools.Schema.SqlTasks.targets



Copyright © 2012 Gert Drapers - All Rights Reserved.             03/29/2012
MSBuild
 123




               msbuild /t:build sqlproj-nw.sqlproj
               msbuild /t:publish sqlproj-nw.sqlproj
                /p:SqlPublishProfilePath=sqlproj-
                nw.publish.xml
               msbuild /t:StaticCodeAnalysis sqlproj-
                nw.sqlproj

Copyright © 2012 Gert Drapers - All Rights Reserved.     03/29/2012
MSBuild Target Definitions
 124




               PreBuildEvent                               BeforePublish
               BeforeBuild                                 PrePublishEvent
               AfterBuild                                  PostPublishEvent
               PostBuildEvent                              AfterPublish
   <Target Name="BeforeBuild">                         <Target Name="BeforePublish">
      <Message Text="BeforeBuild message" />              <Message Text="BeforePublish message" /
   </Target>                                           >
   <Target Name="AfterBuild">                          </Target>
      <Message Text="AfterBuild message" />            <Target Name="AfterPublish">
   </Target>                                              <Message Text="AfterPublish message" />
Copyright © 2012 Gert Drapers - All Rights Reserved.
                                                       </Target>                            03/29/2012
Microsoft.SqlServer.Dac.dll
 125




               Public API
                 Implements  the common DAC verbs
                 Deploy, ExportBacpac, Extract, GenerateCreateS
                  cript, GenerateDeployReport, GenerateDeployScr
                  ipt, GeneratedriftReport, ImportBacpac, Register,
                  Unregister, Unpack
                 C:Program Files (x86)Microsoft SQL
                  erver110DACbinMicrosoft.SqlServer.Dac.dll
Copyright © 2012 Gert Drapers - All Rights Reserved.            03/29/2012
126               Summary




Copyright © 2012 Gert Drapers - All Rights Reserved.   03/29/2012
SQL Server Data Tools – Summary
127



         Developer-focused toolset to author, debug and
          publish SQL Server & SQL Azure databases

         Supports SQL Platform
             Free, web updates for SQL Server and SQL Azure
              releases
             Works in concert with other SQL Server tooling
              (SAMP, SSMS)
         Compatible with your development environment
                    Supports Visual Studio 2010 & Visual Studio 11
                 Migrates VS2010 database projects
Copyright © 2012 Gert Drapers - All Rights Reserved.                  03/29/2012
Widescreen Test Pattern (16:9)




                                                        Aspect Ratio
                                                           Test
                                                        (Should appear
                                                           circular)




                      4x3


     16x9
Copyright © 2012 Gert Drapers - All Rights Reserved.                            03/29/2012

Mais conteúdo relacionado

Mais procurados

SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginnersSQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginnersTobias Koprowski
 
Introducing Microsoft SQL Server 2012
Introducing Microsoft SQL Server 2012Introducing Microsoft SQL Server 2012
Introducing Microsoft SQL Server 2012Intergen
 
Maximizing sql 2012 performance for share point 2013 final
Maximizing sql 2012 performance for share point 2013 finalMaximizing sql 2012 performance for share point 2013 final
Maximizing sql 2012 performance for share point 2013 finalVinh Nguyen
 
Sql server 2016 new features
Sql server 2016 new featuresSql server 2016 new features
Sql server 2016 new featuresAjeet Singh
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufCTE Solutions Inc.
 
Database CI Demo Using Sql Server
Database CI  Demo Using Sql ServerDatabase CI  Demo Using Sql Server
Database CI Demo Using Sql ServerUmesh Kumar
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's Newdpcobb
 
First Look to SSIS 2012
First Look to SSIS 2012First Look to SSIS 2012
First Look to SSIS 2012Pedro Perfeito
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and EnhancementsSQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and EnhancementsJohn Martin
 
SQL Server 2016: Just a Few of Our DBA's Favorite Things
SQL Server 2016: Just a Few of Our DBA's Favorite ThingsSQL Server 2016: Just a Few of Our DBA's Favorite Things
SQL Server 2016: Just a Few of Our DBA's Favorite ThingsHostway|HOSTING
 
PASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and BaseliningPASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and BaseliningPARIKSHIT SAVJANI
 
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction Mark Ginnebaugh
 
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!Nicolas Morales
 
ZK MVVM, Spring & JPA On Two PaaS Clouds
ZK MVVM, Spring & JPA On Two PaaS CloudsZK MVVM, Spring & JPA On Two PaaS Clouds
ZK MVVM, Spring & JPA On Two PaaS CloudsSimon Massey
 
SSIS 2012: Parameters vs. Configurations
SSIS 2012: Parameters vs. ConfigurationsSSIS 2012: Parameters vs. Configurations
SSIS 2012: Parameters vs. ConfigurationsAllen Smith
 

Mais procurados (20)

SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginnersSQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
 
Introducing Microsoft SQL Server 2012
Introducing Microsoft SQL Server 2012Introducing Microsoft SQL Server 2012
Introducing Microsoft SQL Server 2012
 
Maximizing sql 2012 performance for share point 2013 final
Maximizing sql 2012 performance for share point 2013 finalMaximizing sql 2012 performance for share point 2013 final
Maximizing sql 2012 performance for share point 2013 final
 
Sql server 2016 new features
Sql server 2016 new featuresSql server 2016 new features
Sql server 2016 new features
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian Malbeuf
 
SQL Server 2016 BI updates
SQL Server 2016 BI updatesSQL Server 2016 BI updates
SQL Server 2016 BI updates
 
Exploring sql server 2016
Exploring sql server 2016Exploring sql server 2016
Exploring sql server 2016
 
Exploring sql server 2016 bi
Exploring sql server 2016 biExploring sql server 2016 bi
Exploring sql server 2016 bi
 
Database CI Demo Using Sql Server
Database CI  Demo Using Sql ServerDatabase CI  Demo Using Sql Server
Database CI Demo Using Sql Server
 
Sql 2016 - What's New
Sql 2016 - What's NewSql 2016 - What's New
Sql 2016 - What's New
 
First Look to SSIS 2012
First Look to SSIS 2012First Look to SSIS 2012
First Look to SSIS 2012
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and EnhancementsSQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and Enhancements
 
SQL Server 2016: Just a Few of Our DBA's Favorite Things
SQL Server 2016: Just a Few of Our DBA's Favorite ThingsSQL Server 2016: Just a Few of Our DBA's Favorite Things
SQL Server 2016: Just a Few of Our DBA's Favorite Things
 
Stretch db sql server 2016 (sn0028)
Stretch db   sql server 2016 (sn0028)Stretch db   sql server 2016 (sn0028)
Stretch db sql server 2016 (sn0028)
 
PASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and BaseliningPASS VC: SQL Server Performance Monitoring and Baselining
PASS VC: SQL Server Performance Monitoring and Baselining
 
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
 
Rich Assad Resume
Rich Assad ResumeRich Assad Resume
Rich Assad Resume
 
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
Big SQL 3.0: Datawarehouse-grade Performance on Hadoop - At last!
 
ZK MVVM, Spring & JPA On Two PaaS Clouds
ZK MVVM, Spring & JPA On Two PaaS CloudsZK MVVM, Spring & JPA On Two PaaS Clouds
ZK MVVM, Spring & JPA On Two PaaS Clouds
 
SSIS 2012: Parameters vs. Configurations
SSIS 2012: Parameters vs. ConfigurationsSSIS 2012: Parameters vs. Configurations
SSIS 2012: Parameters vs. Configurations
 

Destaque

The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)Charles B. Hall, CPA, CFE
 
Mobile GREE Research Report V1.0
Mobile GREE Research Report V1.0Mobile GREE Research Report V1.0
Mobile GREE Research Report V1.0Infinita Inc.
 
Deciphering Digital Distruption - The Future Is Always Beginning Now
Deciphering Digital Distruption -  The Future Is Always Beginning Now Deciphering Digital Distruption -  The Future Is Always Beginning Now
Deciphering Digital Distruption - The Future Is Always Beginning Now HCL Infosystems
 
Using the CC BY license, Workshop for 2013 OPEN Kick-off
Using the CC BY license, Workshop for 2013 OPEN Kick-offUsing the CC BY license, Workshop for 2013 OPEN Kick-off
Using the CC BY license, Workshop for 2013 OPEN Kick-offJane Park
 
Stanford Marketing 7 08
Stanford Marketing 7 08Stanford Marketing 7 08
Stanford Marketing 7 08jenyipCC
 
Slide guide for consulting-style presentations
Slide guide for consulting-style presentationsSlide guide for consulting-style presentations
Slide guide for consulting-style presentationsreallygoodppts
 

Destaque (7)

The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)
 
Strategy
Strategy Strategy
Strategy
 
Mobile GREE Research Report V1.0
Mobile GREE Research Report V1.0Mobile GREE Research Report V1.0
Mobile GREE Research Report V1.0
 
Deciphering Digital Distruption - The Future Is Always Beginning Now
Deciphering Digital Distruption -  The Future Is Always Beginning Now Deciphering Digital Distruption -  The Future Is Always Beginning Now
Deciphering Digital Distruption - The Future Is Always Beginning Now
 
Using the CC BY license, Workshop for 2013 OPEN Kick-off
Using the CC BY license, Workshop for 2013 OPEN Kick-offUsing the CC BY license, Workshop for 2013 OPEN Kick-off
Using the CC BY license, Workshop for 2013 OPEN Kick-off
 
Stanford Marketing 7 08
Stanford Marketing 7 08Stanford Marketing 7 08
Stanford Marketing 7 08
 
Slide guide for consulting-style presentations
Slide guide for consulting-style presentationsSlide guide for consulting-style presentations
Slide guide for consulting-style presentations
 

Semelhante a SSDT Workshop @ SQL Bits X (2012-03-29)

Declarative Database Development with SQL Server Data Tools
Declarative Database Development with SQL Server Data ToolsDeclarative Database Development with SQL Server Data Tools
Declarative Database Development with SQL Server Data ToolsGert Drapers
 
Oracle BPM workflow and Open-XDX web services (Part 2)
Oracle BPM workflow and Open-XDX web services (Part 2)Oracle BPM workflow and Open-XDX web services (Part 2)
Oracle BPM workflow and Open-XDX web services (Part 2)Bizagi Inc
 
An overview of microsoft data mining technology
An overview of microsoft data mining technologyAn overview of microsoft data mining technology
An overview of microsoft data mining technologyMark Tabladillo
 
Sqlsat154 maintain your dbs with help from ola hallengren
Sqlsat154 maintain your dbs with help from ola hallengrenSqlsat154 maintain your dbs with help from ola hallengren
Sqlsat154 maintain your dbs with help from ola hallengrenAndy Galbraith
 
Oracle - Enterprise Manager 12c Overview
Oracle - Enterprise Manager 12c OverviewOracle - Enterprise Manager 12c Overview
Oracle - Enterprise Manager 12c OverviewFred Sim
 
Senior database administrator
Senior database administratorSenior database administrator
Senior database administratorMustafa EL-Masry
 
Model Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & FutureModel Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & Futureelliando dias
 
SQL Server 2008 Highlights
SQL Server 2008 HighlightsSQL Server 2008 Highlights
SQL Server 2008 HighlightsIntergen
 
Apoyo en la administración de bases de datos mediante microsoft data tools
Apoyo en la administración de bases de datos mediante microsoft data toolsApoyo en la administración de bases de datos mediante microsoft data tools
Apoyo en la administración de bases de datos mediante microsoft data toolsSpanishPASSVC
 
An overview of Microsoft data mining technology
An overview of Microsoft data mining technologyAn overview of Microsoft data mining technology
An overview of Microsoft data mining technologyMark Tabladillo
 
Eclipse Developement @ Progress Software
Eclipse Developement @ Progress SoftwareEclipse Developement @ Progress Software
Eclipse Developement @ Progress Softwaresriikanthp
 
SQLUG event: An evening in the cloud: the old, the new and the big
 SQLUG event: An evening in the cloud: the old, the new and the big  SQLUG event: An evening in the cloud: the old, the new and the big
SQLUG event: An evening in the cloud: the old, the new and the big Mike Martin
 
Secrets of Enterprise Data Mining
Secrets of Enterprise Data Mining Secrets of Enterprise Data Mining
Secrets of Enterprise Data Mining Mark Tabladillo
 
Azure presentation nnug dec 2010
Azure presentation nnug  dec 2010Azure presentation nnug  dec 2010
Azure presentation nnug dec 2010Ethos Technologies
 

Semelhante a SSDT Workshop @ SQL Bits X (2012-03-29) (20)

Declarative Database Development with SQL Server Data Tools
Declarative Database Development with SQL Server Data ToolsDeclarative Database Development with SQL Server Data Tools
Declarative Database Development with SQL Server Data Tools
 
Oracle BPM workflow and Open-XDX web services (Part 2)
Oracle BPM workflow and Open-XDX web services (Part 2)Oracle BPM workflow and Open-XDX web services (Part 2)
Oracle BPM workflow and Open-XDX web services (Part 2)
 
SQL Azure Overview
SQL Azure OverviewSQL Azure Overview
SQL Azure Overview
 
Sql Azure
Sql AzureSql Azure
Sql Azure
 
An overview of microsoft data mining technology
An overview of microsoft data mining technologyAn overview of microsoft data mining technology
An overview of microsoft data mining technology
 
Sqlsat154 maintain your dbs with help from ola hallengren
Sqlsat154 maintain your dbs with help from ola hallengrenSqlsat154 maintain your dbs with help from ola hallengren
Sqlsat154 maintain your dbs with help from ola hallengren
 
Oracle - Enterprise Manager 12c Overview
Oracle - Enterprise Manager 12c OverviewOracle - Enterprise Manager 12c Overview
Oracle - Enterprise Manager 12c Overview
 
Senior database administrator
Senior database administratorSenior database administrator
Senior database administrator
 
Model Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & FutureModel Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & Future
 
SQL Server 2008 Highlights
SQL Server 2008 HighlightsSQL Server 2008 Highlights
SQL Server 2008 Highlights
 
Apoyo en la administración de bases de datos mediante microsoft data tools
Apoyo en la administración de bases de datos mediante microsoft data toolsApoyo en la administración de bases de datos mediante microsoft data tools
Apoyo en la administración de bases de datos mediante microsoft data tools
 
An overview of Microsoft data mining technology
An overview of Microsoft data mining technologyAn overview of Microsoft data mining technology
An overview of Microsoft data mining technology
 
Eclipse Developement @ Progress Software
Eclipse Developement @ Progress SoftwareEclipse Developement @ Progress Software
Eclipse Developement @ Progress Software
 
Patel v res_(1)
Patel v res_(1)Patel v res_(1)
Patel v res_(1)
 
SQLUG event: An evening in the cloud: the old, the new and the big
 SQLUG event: An evening in the cloud: the old, the new and the big  SQLUG event: An evening in the cloud: the old, the new and the big
SQLUG event: An evening in the cloud: the old, the new and the big
 
Lalith Thota
Lalith ThotaLalith Thota
Lalith Thota
 
Bynet2.3 Adobe Flex builder 4
Bynet2.3 Adobe Flex builder 4Bynet2.3 Adobe Flex builder 4
Bynet2.3 Adobe Flex builder 4
 
Secrets of Enterprise Data Mining
Secrets of Enterprise Data Mining Secrets of Enterprise Data Mining
Secrets of Enterprise Data Mining
 
Confio presentation
Confio presentationConfio presentation
Confio presentation
 
Azure presentation nnug dec 2010
Azure presentation nnug  dec 2010Azure presentation nnug  dec 2010
Azure presentation nnug dec 2010
 

Último

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 

SSDT Workshop @ SQL Bits X (2012-03-29)

  • 1. SQL SERVER DATA TOOLS WORKSHOP Everything you need to know to get started
  • 2. Slides 2  SQLProj.com  http://sqlproj.com/index.php/2012/03/sqlbits-2012- ssdt-workshop/  Slides:  http://sqlproj.com/wp-content/uploads/2012/03/SSDT- Workshop-2012-03-29-final.pdf  Handout  http://sqlproj.com/wp-content/uploads/2012/03/SSDT- Workshop-2012-03-29-handout.pdf Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 3. 3 Introduction gert.drapers@microsoft.com Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 4. Copyright and Disclaimer 4  This presentation, including examples are provided for informational purposes only, the author makes no warranties, either express or implied.  Information in this presentation, including samples, URL and other Internet Web site references, are subject to change without notice.  Complying with all applicable copyright laws is the responsibility of the user.  Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of the author.  The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 5. @DataDude 5  1986-1988 IBM Corporation  1988-1991 Ashton-Tate  1991-present Microsoft Corp.  SDE in the Developer Relations Group (the Netherlands)  Senior Development Consultant in MCS (the Netherlands)  SDE in Storage Engine (DBCC, Bulk Insert and Convert)  Program Manager SQL-DMO and Query Analyzer  Product Unit Manager SQL Server Management Tools  Software Architect DTS 2005 (now SSIS) and SMO  Software Architect MS-DTC, COM+, System.Transactions, WS-AT  Software Architect SQL Server Customer Advisory Team (Europe)  Principal Group Engineering Manager “Visual Studio Team System Database Edition”  Principal Software Architect Azure Active Directory  Principal Software Architect Cloud Programmability (SQL)  Principal Group Program Manager SQL Server Data Platform Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 6. Agenda 6  SQL Server Data Tools Overview  SQL Server Data Tools Installation  Data-Tier Application Component (DAC)  Declarative Database Development  Connected Development  Project Based Development  Application Life Cycle Integration  Programmatic and Command Line Usage Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 7. 7 SQL Server Data Tools Overview Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 8. Database Development Challenges 8  Databases are inherently stateful  Focus is on ALTER instead of CREATE  Dependencies complicate scripts  Errors are often found only when scripts are executed  Synchronizing application and database versions  Database development often not integrated in to application life cycle management and processes  Targeting different SQL Server and SQL Azure versions Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 9. History of the “DataDude” Project 9  Project funded April 2005  Project started July 1st 2005  Visual Studio 2005 Team System for Database Professionals  Visual Studio 2008 Team System for Database Professionals  Re-architected to be declarative model based system  Visual Studio 2008 Team System for Database Professionals GDR R2  Visual Studio 2010 Team System for Database Professionals  Transitioned to SQL Server 2009  SQL Server Data Tools Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 10. Introducing SQL Server Data Tools 10 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 11. Connected Development 11 T-SQL IntelliSense Drift Detection Table Designer SQL Server Object Explorer T-SQL Debugging View Code Schema Comparison T-SQL Editor View/Edit Data Error Information Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 12. Project Based Development 12 Source Code Point-in-time Go To Definition Source Code Based Snapshots Control Visualize Schema Find All References F5 Debugging & MSBuild Differences Testing with Headless LocalDB T-SQL Static Code Refactoring Command Line Analysis Tools Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 13. Schema Deployment 13 Model Based SQL Server 2005 DACPAC Format SQL Server 2008 SQL Server 2012 Incremental SQL Azure Connected Engine Schema Deployment Retargeting Support SQL Script API & REDIST Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 14. SQL Azure Management Portal Import Publish Export Compare Register Sync Unregister DAC SQL Server Data Tools SQL Server Management Studio Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 15. Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 16. Resources 16  SQL Server Data Tools Online Installation  http://msdn.microsoft.com/data/tools Get It  Team Blog  http://blogs.msdn.com/b/ssdt/  MSDN Forum  http://social.msdn.microsoft.com/Forums/en- US/ssdt/threads  Articles  MSDN Magazine Sept 2011 The "Juneau" Database Copyright © 2012 GertProject Drapers - All Rights Reserved. 03/29/2012
  • 17. SQL Server Data Tools 17 Installation Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 18. Setup Options 18  Install from online Web Platform Installer feed  Install from SQL Server 2012 DVD  Install from Visual Studio 11  Install from offline administrative install Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 19. Supported OS Platforms 19  Windows Vista SP2+  Windows 7 SP1+  Windows Server 2008 SP+  Windows Server 2008 R2 SP1+  Note: this is different then the Visual Studio 2010 platforms Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 20. Visual Studio Requirements 20  Visual Studio 2010 Integrated Shell+  SQL-CLR requires Visual Studio 2010 Standard+  Visual Studio 2010 SP1+  Notes:  SQL Server 2012 only installs VS 2010 Integrated Shell SP1  If you have an existing Visual Studio 2010 installation you must install SP1 yourself (?KB VS2010 SP1 checks)  Watch for mixed mode (?KB detecting mixed mode) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 21. SSDT Online Acquisition 21  Install online via Web Platform Installer (WebPI)  SSDT download link for latest bits  http://msdn.microsoft.com/en-us/data/hh297027  Requires WebPI v3.0 or better to be installed  User is prompted on first attempt when not installed or updated  Automatically downloads all required new or updated dependencies  Invokes SSDTSetup.exe (chained installer) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 22. Installing from SQL Server 2012 DVD 22  Install SSDT from SQL Server 2012 DVD image  Install VS 2010 SP1 shell if you do not have VS installed  If you do have VS 2010 install, user needs to install SP1!  DVD puts down a “stub” which will acquire latest SSDT bits online via (WebPI)  See http://sqlproj.com/index.php/2011/11/ssdt-setup- from-sql-server-2012/ for detailed step through Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 23. Creating an Admin Install 23  SSDTSetup.exe /layout C:SSDTAdminInstall  Pulls down all the latest dependencies from the web  Enables generating a local install point which can be shared via a file share or USD drive  DMZ or offline installation scenario  For detailed steps see:  http://sqlproj.com/index.php/2011/11/creating-an- administrative-install-for-ssdt Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 24. SSDTSetup 24  SSDTSetup.exe  Setup chainer (486 KB)  SSDTx86SSDT.msi  Actual tools (5.75 MB)  SSDTx86SSDTBuildUtilities.msi  MSBuild targets and utilities (970 KB)  SSDTx86DbSqlPackageProvider.msi  Web Deploy Provider (729 KB) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 25. Setup Dependencies (payload directory) 25  x86DACFramework.msi  dotNetFx40_Full_x86_x64.exe  x86NDP40-KB2468871-v2-x86.exe  NDP40-KB2544514-x86-x64.exe  x86SharedManagementObjects.msi  x64DACFramework.msi  x86SQLDom.msi  x64NDP40-KB2468871-v2-x64.exe  x86SqlLocalDB.msi  x64SharedManagementObjects.msi  x86sqlls.msi  x64SQLDom.msi  x86SQLSysClrTypes.msi  x64SqlLocalDB.msi  x86SSDTDBSvcExternals.msi  x64sqlls.msi  x86TSqlLanguageService.msi  x64SQLSysClrTypes.msi  x86VS10sp1-KB983509.exe  x64TSqlLanguageService.msi  x86VSIntShell.exe Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 26. Setup Dependencies 26  .NET 4.0 CLR runtime  dotNetFx40_Full_x86_x64.exe  .NET 4.0 CLR general update  http://support.microsoft.com/kb/2468871  NDP40-KB2544514-x86-x64.exe  Update 4.0.2 for Microsoft .NET Framework 4 – Runtime Update  http://support.microsoft.com/kb/2544514  NDP40-KB2544514-x86-x64.exe  LocalDB support  Visual Studio 2010 integrated shell  VSIntShell.exe  Visual Studio 2010 SP installer  VS10sp1-KB983509.exe  http://support.microsoft.com/kb/983509 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 27. Setup Dependencies… 27  SQL Server 2012 Data-Tier Application Framework v3.0  DACFramework.msi  SQL Server 2012 Express LocalDB  SqlLocalDB.msi  SQL Server 2012 Script DOM (parser)  SQLDom.msi  SQL Server 2012 Language Services (compiler and binder)  sqlls.msi  SQL Server 2012 CLR types (geo and hierarchy)  SQLSysClrTypes.msi  SQL Server 2012 Management Objects (SMO)  SharedManagementObjects.msi  SQL Server 2012 Language Services (IntelliSense parser)  TSqlLanguageService.msi Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 28. Headless Installation 28  Install the five following components:  SQL Server 2012 Data-Tier Application Framework (DACFramework.msi)  SQL Server 2012 Transact-SQL ScriptDom (SQLDOM.MSI)  SQL Server 2012 Transact-SQL Compiler Service (SQLLS.MSI)  Microsoft System CLR Types for Microsoft SQL Server 2012 (SQLSysClrTypes.msi)  SQL Server Data Tools Build Utilities (SSDTBuildUtilities.msi)  NOTE: Need to copy from SSDT Administrative install point  For detailed description see:  http://sqlproj.com/index.php/2012/03/headless-msbuild-support-for-ssdt- sqlproj-projects/ Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 29. Visual Studio 2012 29  SQL Server Database Projects are a standard feature in Visual Studio 2012  Replaces Visual Studio Database Projects  Available in Visual Studio Professional edition and up  Integrate shell version will be made available separately as online download  Visual Studio 2012 RTM will ship with the same functionality as the SSDT version shipping with SQL Server 2012 RTM  Round tripping of projects and project artifacts between VS2010 and VS2012 hosted SQL Server Database Projects Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 30. Setup Log Files 30  dir %temp%sql_SSDT_1000*.log  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_0_SQLLS11X64.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_1_SQLDOM11X64.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_2_TSQLLANGSVC11X64.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_3_DACFX11X86.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_4_DACFX11X64.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_5_SQLLOCALDBX64.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_6_SQLCLRTYPES11X86.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_7_SQLCLRTYPES11X64.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_8_SQLSMO11X86.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_9_SQLSMO11X64.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_10_SSDTEXTERNALS10.log“  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_11_SSDTBUILDUTILITIES10.log"  "C:UsersgertdAppDataLocalTempsql_SSDT_1000_20120218114502_12_SSDT10.log" Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 31. 31 Declarative Database Development The foundation Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 32. Simple Schema Versioning Example 32 -- version 1 -- version 2 CREATE TABLE dbo.Auction ALTER TABLE dbo.Auction ( WITH CHECK ADD CONSTRAINT Au_PK id INT NOT NULL, name VARCHAR(25) NOT NULL, -- version 3 start DATETIME NULL, ALTER TABLE dbo.Auction len INT NULL WITH CHECK ) ADD CONSTRAINT Au_SK UNIQUE (name) V1 V2 V3 Revision History Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 33. Imperative 33  Imperative scripts hard codes knowledge about:  The state of the target system:  Presence of objects, dependencies, unbinding, rebinding  Required ordering of operations  Cumulative changes need to be serialized  v1v2v3v4v5 instead of v1v4v5  Validating the end-result against expected end-state is hard  No easy way to compare expected vs. actual  Batching or separating multiple changes Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 34. Imperative Versioning 34 -- version 1 Add table dbo.Auction IF OBJECT_ID (N'dbo.Auction', N'U') IS NULL BEGIN CREATE TABLE dbo.Auction (` id INT NOT NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL ) END -- version 2 Add PK Au_PK IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_PK' AND type = 'PK') BEGIN ALTER TABLE Auction WITH CHECK ADD CONSTRAINT Au_PK PRIMARY KEY (id) END -- version 3 Add UC Au_SK IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_SK' AND type = ‘UQ') BEGIN ALTER TABLE Auction WITH CHECK ADD CONSTRAINT Au_SK UNIQUE (name) END Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 35. Declarative 35  Define what you want in the form of a model  Fill the model using a DSL (domain specific language)  T-SQL  Use the model as the starting point “blueprint” for all operations  Deployment/publish, start by comparing the current state of the target with the required state (blueprint)  Use the resulting difference knowledge to programmatically generate an deployment plan  Use plan to create sequence of (SQL) statements required to make the target state become like the blueprint state Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 36. Declarative Versioning 36 -- version 1 CREATE TABLE dbo.Auction -- version 2 ( CREATE TABLE dbo.Auction -- version 3 id ( INT NOT NULL, dbo.Auction CREATE TABLE name id ( INT NOT NOT NULL, VARCHAR(25) NULL PRIMARY KEY, start DATETIME INT NOT NOT NULL, name id NULL, VARCHAR(25) NULL PRIMARY KEY, len start NULL VARCHAR(25) NOT NULL UNIQUE, INTname DATETIME NULL, ) len start NULL INT DATETIME NULL, ) len INT NULL ) V1 V2 V3 Revision History Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 37. Declarative Schema Deployment 37 37 Source Target Model Reverse Schema Schema Compare Engineer Model Model Diff List Plan Optimizer Additional schema Deploy Plan artifacts Script Generator Script Target Executor Incremental target update DB Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 38. Imperative vs. Declarative 38  Manual vs. generated / programmatic  Point in time vs. always current  Sequential vs. differential Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 39. Script Fundamentals 39  Requirement to be able to round trip DSL A artifacts S T  Script  Model Script  SQL script Parse T-SQL Parser Script fragment Fragment  Script fragment Script Gen  SQL script Script Script Gen T-SQL  Script fragment is AST Fragment (Abstract Syntax Tree) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 40. ScriptDom 40  SQL Server 2012 managed parser  Supports SQL Server 2005+  Class TSqlXXXParser  XXX = [80, 90, 100, 110]  SQLDom.msi (redist x86/x64)  Microsoft.SqlServer.TransactSql.ScriptDom.dll  C:Program Files (x86)Microsoft SQL Server110SDK AssembliesMicrosoft.SqlServer.TransactSql.ScriptDom.dll  GAC Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 41. Basic ScriptDom loop 41 static void Main(string[] args) { bool initialQuotedIdentifiers = false; TSqlParser parser = new TSql110Parser(initialQuotedIdentifiers); StreamReader sr = new StreamReader(@".test.sql"); IList<ParseError> errors; TSqlFragment fragment = parser.Parse(sr, out errors); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); Sql110ScriptGenerator scriptGen = new Sql110ScriptGenerator(); scriptGen.GenerateScript(fragment, sw); } Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 42. Reusable Building Blocks 42  Model Store  Model Builder  Model Serialization  Model Comparison  Model Copy Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 43. Model Store 43  Elements  Models are stored in  Relationships ESE database or in- memory  Properties  *.dbmdl (Database  Identifiers Model) file extension  Annotations used by local model cache. Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 44. Model Builder 44  The schema model is populated using information from the AST representation of the SQL parser  From a model element you can recreate a script fragment (AST) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 45. Model Serialization 45  Act of serializing and de-serializing a schema model to and from disk or in- memory persistence model  Model is serialized as XML  See digesting a Copyright © 2012 GertDACPAC Drapers - All Rights Reserved. 03/29/2012
  • 46. Digesting a .DACPAC 46  OPC file  Unpack handler associated at file system level  Rename .dacpac to .zip to open  Compressed  Versioned  SQL Server 2012 ships with DACPAC version 3.0.0.0  http://en.wikipedia.org/wiki/Open_Packaging_Convent ions Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 47. .DACPAC streams 47 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 48. Reverse Engineer 48  Reverse Engineering is a special form of model builder, which scripts the content of a source database in the form of SQL scripts (model DSL input format) to construct a model Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 49. Model Copy / Compare 49  Comparing two declarative models to determine the difference  The comparison engine exposes options for excluding object instances, object types, specific options on objects and certain Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 50. Deployment & Schema Compare 50 Script Script Model Model Builder Builder Fragment Fragment Source Target Reverse Reverse DB Schema Schema DB Engineer Engineer Model Model Model Schema Model Compare Model Schema Package Serializer Serializer Package Diff List Plan Diff Optimizer Visualizer Deploy Plan Script Copyright © 2012 Gert Drapers - All Rights Reserved. Generator 03/29/2012
  • 51. Model Based 51 .SQL SqlScript Schema Parse Dom Interpret Validate Source Model  All schema objects are represented inside a model  What is in the model is defined by the provider  To load/hydrate a model instance  Parse  SqlCodeDom, based on parsers Abstract Syntax Tree (AST)  Interpretation Schema Model  Symbol list  Object References (hard and soft dependencies)  Validation Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 52. Component Stack 52 SQL Server Data Tools TSQL DACFX SMO System.Data. SqlClient Language Services NetFX Patches Visual Studio SQLLS SQLDOM SQLCLRTypes LocalDB VS2010 SP1, VS2012 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 53. Data-Tier Application 53 Component DAC Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 54. What is a Data-Tier Application (dacpac)? 54  Data-Tier Application Component (DAC)  SQL Server database registered as Data-Tier Application Component  DAC is a self contained entity of a database used by an application  Unit of deployment and management  Authored along side your application code  Compiled into a DAC package (DACPAC)  Extracted for existing databases  Database extracted (DACPAC) or exported (BACPAC) into packages  Package is deployable to SQL Server and SQL Azure Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 55. DAC Framework v3.0 (DACFX) 55  Core SQL Server redist component providing modeling, reverse engineering and deployment capabilities  Managed Public API  Exposes verbs for DACPAC and BACPAC package operations  Command-line tool (SqlPackage.exe)  Executable over the managed public API  DACUnpack.exe  Windows file handler for unpacking DACPACs to disk  DACFX Clients  SqlPackage.exe, SSMS, SSDT, SAMP, I&E, VS Web and DB Publishing Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 56. DACFX Packages 56  .dacpac - Packaged Schema representing the declarative model of the database  Not SQL, but a declarative Schema Model representation of the database  Compiled from source code or Extracted from existing databases  Deploy as new database or Incremental Upgrade an existing database  Supports all SQL Server Objects and Types  .bacpac - Packaged Schema and Data representing the state of the database  Composed of Schema Model with stateful properties and Data Streams  Exported from existing databases  Imported as a new database or populates an empty database  Supports most SQL Server Objects and Types (SQL Azure parity) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 57. DAC Evolution 57 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 58. DACFX Supported SQL Server Objects and Versions 58  SQL Server 2012 DACFX (v3.0) supports the full SQL Server Domain  Supports the following versions:  SQL Server 2005  SQL Server 2008/R2  SQL Server 2012  SQL Azure  DACFX (v3.0) backwards compatibility  DACFX 1.0, 1.1, and 2.0 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 59. Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 60. SQL Server Data Tools 60  Developer-focused toolset for authoring, building and publishing DACPACs  Experiences Enabled  Connected Development  Project Based Development  Application Lifecycle & Tools  DACPAC verbs  Author DACPAC declaratively and build from source  Compare DACPAC to project, database, and other DACPACs  Import DACPAC into project  Publish DACPAC/Project to database Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 61. SQL Server Management Studio 61  DBA-focused tools for deploying and extracting DACPACs; importing and exporting BACPACs  Experiences Enabled  Administration and Monitoring  Connected Development  Configuration and Task Wizards  DACPAC Verbs Supported  Deploy Data Tier Application  Register/Unregister Data Tier Application  Upgrade Data Tier Application  BACPAC Verbs Supported  Import Data Tier Application  Export Data Tier Application  Migrate Database to SQL Azure Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 62. SQL Azure Management Portal 62  Subscriber and Operator oriented toolset for managing SQL Azure databases through DAC Verbs  Experiences Enabled  Connected Development  Portal Based Tools  Application Lifecycle support  DACPAC verbs supported  Deploy Data Tier Application (create new database from dacpac)  Upgrade Data Tier Application (upgrade database to match dacpac)  Extract Data Tier Application (create dacpac from existing database)  BACPAC Verbs supports  Export Data Tier Application (export database as bacpac to Windows Azure Blob Storage)  Import Data Tier Application (import bacpac as new database from Windows Azure Blob Storage) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 63. DAC Lifecycle 63 Developer DBA DBA/Admin Develop (SSDT) Deploy (SSMS) Manage (SSMS and SAMP) • Import Database/ • Deploy Package • Export and Extract DACPAC • New Databases Packages • Author DAC • Upgrade Databases • Register Database as DAC • Compare and Synchronize Source • Compile Database Project to DACPAC • Publish DACPAC Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 64. 64 Connected Development Imperative & Declarative Schema Authoring and Deployment Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 65. Connected Development 65  SQL Server Object Explorer (SSOX)  T-SQL Editor/Debugger/IntelliSense (New Query)  Power-Buffer (New Object/View Code)  Table Designer (View Designer)  Data Editor (View Data)  Execute Procedure/Function  Schema Compare Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 66. SQL Server Object Explorer (SSOX) 66  The SQL Server navigation tool window  Modeled after the SSMS Object Explorer  Server scoped vs. Server Explorer which is database scoped  Launch point for T-SQL Editor, Debugger, Object Execution, Designers, …  Supports connecting directly to SQL Server  SQL Server {2005, 2008, 2008R2, 2012} and SQL Azure  Supports connecting directly to a (contained) database  Constructs a partial model in the background and under the covers  Supports:  Cascading Drops and Renames  Drift detection  Automatically updates the tree/source as changes occur on the server  SSOX is a DSRef drag source Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 67. SSOX Drift Detection 67  Controlling Refresh Rate  HKEY_CURRENT_USERSoftwareMicrosoftVis ualStudio10.0SQLDBDialogPageMicrosoft.Visu alStudio.Data.Tools.Package.ToolsOptions.Online Editing.OnlineEditingOptionsSettings] "PollingDriftCheckSeconds"="30"  Defaults to 30. If set to <= 0 will be infinite (3 days). Cannot be less than 30. Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 68. T-SQL Editor/Debugger/IntelliSense 68  T-SQL IntelliSense  Other Options:  SQL Server 2005+ incl. SQL  Actual Execution Plan Azure  SQLCMD mode  Result to Grid | Text | File  Client Statistics  Execution modes  Code snippets  Parse  Reusable debug script  Estimated Execution Plan generation  Execute  Keyboard shortcut mapping  Execute with debugger alignment  Out-of-band delivery of SSMS Copyright © 2012 Gert Drapers - All Rights Reserved. profile 03/29/2012
  • 69. T-SQL Editor Keyboard Mapping 69 Commands SSMS Keyboard Compatibility Settings SQL Server Development Settings Execute CTRL+E / ALT+X / CTRL+SHIFT+E CTRL+SHIFT+E Execute w/Debugger ALT+F5 ALT+F5 Cancel Query Execution ALT+BREAK ALT+BREAK Include Actual Execution Plan CTRL+M CTRL+D, A Display Estimated Execution Plan CTRL+L CTRL+D, E Results As Grid CTRL+D CTRL+D, G Results As Text CTRL+T CTRL+D, T Results As File CTRL+SHIFT+F CTRL+D, F Show/Hide Results CTRL+R CTRL+D, R New File CTRL+N None defined http://blogs.msdn.com/b/ssdt/archive/2012/03/07/using-ssms-keyboard-mappings-in-ssdt.aspx Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 70. T-SQL Editor/Debugger/IntelliSense 70  Toolbar consistencyInclude SSMS Display with Estimated Actual SQLCMD Parse Execution Execution Mode Plan Plan Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 71. T-SQL Editor/Debugger/IntelliSense 71  Context menu consistency improvement Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 72. Power-Buffer/Table Designer 72  Declarative deferred online schema management  Brings “project-oriented” features to online / connected development  Live errors and warnings as changes are made against code  “Project-oriented” validation during editing  Table designer  Code-behind designer  Works on top of Power-Buffer (partial model) or project model  Strives to be the same experience online as experienced in the project system  Coordinated execution of buffers against the same target  Diff scripts by default are transactional (ToolsOptionsSQL Server ToolsOnline EditingInclude transactional scripts) Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 73. Data Editor 73  View and Edit Data via grid editor  Copy-Paste support  Generate as INSERT to file or query window Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 74. Execute Procedure/Function 74  Dialog based input for parameter collection  Generates SQL script for execution/debugging Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 75. Schema Compare 75  Performs a model comparison between:  Databases  Projects  DACPAC files (snapshots, build outputs, extracts)  Supports:  Refactoring log  SQLCMD variables Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 76. Schema Compare 76  Behavioral comparison options  Object type filtering  Applicationscoped  Non-application scoped Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 77. Schema Compare 77 Next and Previous move between top- Simpler set of columns are aligned around the central level objects, no longer expand the tree. action column echoes alignment of schemas above Group-by Action is the Same default column order is used for all groupings; cleaner and Schema no longer easier to used as a parent for parse top-level objects; only regardless of shown when changed grouping Improved script diff’ algorithm for tables emphasizes columns as unit of change. Gives much improved alignment. Also improved look Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 78. Schema Compare 78 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 79. 79 Project Based Development Offline and Isolated Schema Authoring and Deployment Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 80. Project Based Development 80  Database Projects  Database References  Publishing Projects Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 81. Database Projects 81  Creating and Importing  Additional Language Services  Isolated Sandbox  Database Schema Snapshots  Build Time Validation  T-SQL Static Code Analysis  SQL-CLR Support  Pre & Post Deployment Scripts Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 82. Creating and Importing 82  Single project template  VSDB note:  No distinction between server or user projects  Server projects are projects with target database set to master  Import from:  Database  DACPAC  SQL Script (multi-file import enabled)  Selective import by using Schema Compare  “Create New Project” from SSOX  Inherits version from source database Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 83. Project Files 83  *.sqlproj  MSBuild based project file  *.sqlproj.user  MSBuild based user specific settings (merged-in)  *.dbmdl  <project>.dbmdl is the schema model cache file  Will get rebuild when deleted  Should not get checked-in, in to source code control (SSC)  ESE (Extensible Storage Engine) database file  http://technet.microsoft.com/en-us/library/bb310772.aspx  Managed interface http://managedesent.codeplex.com/ Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 84. Folder Structure 84  Options on import:  None  Schema  Object type  SchemaObject type Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 85. Project Directory Guidelines 85  The projects directory root path is the only thing that matters!  This is determined based on the location of the .sqlproj file  You have to stay underneath this location  All file paths are relative to this location  The initial project structure is a good starting point and works for all objects  You can change the complete directory structure  But if you remove the default layout we do not know where the automatically place objects when using “Add New Item” or when using Import Script  Result: Objects will be placed in the project root location  Advice: Extend the base structure, do not replace Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 86. Project Directory Guidelines… 86  Be aware of MAX_PATH (260 characters)  All relative file locations must fit within MAX_PATH  Your SCC environment might have problems when you exceed MAX_PATH  Choose your project root location wisely  Filenames encoding:  objectname.sql or schema.objectname.sql  <sysname>.<sysname>.sql  sysname = max 128 characters Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 87. Project Directory Guidelines… 87  Be aware of empty directories when using Source Code Control  Placement of new objects when using Add New Item or when using Schema Compare end up in the project root when location is not present  Do not host more then one table inside script file  Table designer will not see additional tables inside script Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 88. Include files 88  Include files  Add Existing Item As Link <Build Include="..Northwind2dboTablesCategories.sql"> <Link>Categories.sql</Link> </Build>  Use to share files between projects  VSDB note:  SQL Server Database Projects do not support partial projects Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 89. Additional Language Services 89  Projects enable additional language services  Go To Definition  Find All References  Refactoring  Rename (sp_rename)  Move to Schema (ALTER SCHEMA schema_name TRANSFER)  Wildcard Expansion  Fully Quality Name  Invoked from Editor, Table Designer and SQL Server Object Explorer for project based schema objects Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 90. Isolated Sandbox 90  F5 – Run by default configure to use the LocalDB instance associated with the project  Data Source=(localdb)<project name>;Initial Catalog=<project name>;Integrated Security=True;Pooling=False;Connect Timeout=30  To retarget to a different SQL Server version and/or shared SQL Server change:  Project propertiesDebugTarget Connection String Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 91. SQL Server 2012 Express LocalDB 91  Simplify embedded usage of SQL Server  Simple installation  Zero-admin database  Same programming surface as User Instances of SQL Express  The same sqlservr.exe as in service-based SQL Server with the same language and features  Connection through the same client-side APIs, using a new connection string option  SQL Server programming symmetry  Installation similar to .NET Framework model  One set of installed binaries (per major version), no global configuration, no constantly-running service  Activation model similar to RANU (Access, SQL Compact, …)  The application connects to a database file, SQL activates automatically  No service: SQL process starts in the context of current user  Default connection string  (localdb)v11.0  http://msdn.microsoft.com/en-us/library/hh510202(v=SQL.110).aspx Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 92. LocalDB Setup 92  Packaged in a small single MSI  SqlLocalDB.msi x32 (27.5 MB)  SqlLocalDB.msi x64 (32.7 MB)  Single registry key to check if LocalDB Runtime is installed C: [HKLMSOFTWAREMicrosoftMicrosoft SQL Server Local Program Files DBInstalled Versions11.0] Microsoft SQL Server 110  Silent installation LocalDB sqlservr.exe SQLLocalDB.msi /Quiet /IAcceptLicenseTerms […] 120  Side-by-side versions LocalDB sqlservr.exe […] Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 93. Each user has their LocalDB instance (process)  Created and started lazily when needed LocalDB Process Model All SQL Server process infrastructure is hidden  Including System Databases (master & friends) 93 Same Machine, Same User Context new SqlConnection( “Server=(LoacalDB)v11.0; AttachDBFile=|DataDirectory|App1DB.mdf“); App1 App1 DB User Code – Visible Infrastructure – Hidden temp model master C:Program Files C:UsersjohnsmithAppData Microsoft SQL Server msdb LocalMicrosoftMicrosoft SQL 110LocalDBBinnsqlservr.exe ServerLocalDBv11.0... Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 94. Database Schema Snapshots 94  Point-in-time representation of schema model  Model must be “error-free” state  Produces same file format (*.dacpac) as build or extract  To be used for:  Versioning  Comparison  Sharing schema definitions or changes … Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 95. Build Time Validation 95  Build validates the complete model  Platform specific validation  Example – Enforces clustered index requirement on tables in SQL Azure  Integration with Compiler Services  Engine-level build-time validation without schema deployment  Leverages CDB and SQL2012 engine capabilities  Pre & Post Deployment scripts  Build validates syntactical correctness of pre- and post- deployment scripts using the SQLCMD variables  Build serializes the model in to model.xml stream inside .dacpac file Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 96. Build Actions 96  Build - This script will be interpreted as T-SQL (or an XML Schema in the case of XML Schema Collections) and reflected in the T-SQL Model  Compile - C# or VB (depending on your project properties) to be deployed as a SQLCLR assembly  None - Use this for any loose artifacts (like text files)  PreDeploy - The pre deployment master script (there can only be one)  PostDeploy - The post deployment master script (there can only be one)  RefactorLog - This is a refactor log which notifies the DaxFx deployment engine that particular changes should be interpreted as refactoring operations and not drop/adds  Build Extension Configuration - Reserved for future use, for this is interpreted as None Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 97. Build Output 97  Build output path  .sqldebug  .sqlrelease  Intermediate output path  .objdebug  .objrelease Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 98. T-SQL Static Code Analysis 98  Rule set  Suppression  Filelevel  Project level  MSBuild support Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 99. SQL-CLR Support 99  Supports:  Embedded C# or VB.NET code artifacts  Deployed as SQL-CLR objects  Binary assembly deployment and SQL-CLR object association  Example:  CREATE TYPE [ClrSchema].[IPv4] EXTERNAL NAME [IPAssembly].[IPv4]; Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 100. Pre & Post Deployment Scripts 100  Can be used for any “arbitrary” SQL actions that you need to perform “before” and “after” deployment of the schema objects  The pre deployment block comes after the generic database context validation block  The post deployment block comes after the schema objects block  Pre and post deployment scripts must be idempotent  They are “executed” each deployment!  http://blogs.msdn.com/gertd/archive/2007/01/25/idempotent- scripts-required.aspx Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 101. Pre & Post Deployment Scripts… 101  The pre or post deployment master files are identified in the .sqlproj file through special item type tags  <PreDeploy Include="ScriptsPre- DeploymentScript.PreDeployment.sql"> <SubType>Code</SubType> </PreDeploy> <PostDeploy Include="ScriptsPost- DeploymentScript.PostDeployment.sql"> <SubType>Code</SubType> </PostDeploy> Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 102. Pre & Post Deployment Scripts… 102  Include files using :r (SQLCMD include)  File paths of includes are relative to the pre or post deployment master file  Included files must exist, even when empty  Not existing include fail will cause an error state at build time  Include files have to be tagged “NotInBuild”  <NotInBuild Include="ScriptsPost- DeploymentDatabaseObjectOptions.sql"> <SubType>NotInBuild</SubType> </NotInBuild> Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 103. SQLCMD Variables 103  Restrictions  Substitution order (vs. sqlcmd.exe)  MSBuild mapping  SQLCMD variables can be used in:  Pre & post deployment scripts  Within schema objects variable have to be placed between square brackets or double or single quotes  [$(var)] or “$(var)” or „$(var)‟  !!!Cannot be used as object identifiers!!!  Variables are defined and store in ???  Configuration dependent ??? Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 104. Database References 104  master and msdb references  3-4 part names  Composition Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 105. Database References 105  Literal vs. variable references  Literal can be used for 2 and 3-part names only  Self vs. 3- vs. 4-part name  Same database  Different database, same server  Different database, different server  Build order and circular references Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 106. Database References 106  File based references (*.dacpac)  Create directory underneath the project root to store dacpac files, to ensure it is a relative path and transports correctly with the project in source code control  Example: Reference*.dacpac  Make sure to point to a v3.0 .dacpac Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 107. master and msdb references 107  master references can be explicit or implicit  master.dbo.<object> or master.sys.<object>  <Annotation Type="AliasedToDbo" />  Global namespace  <Annotation Type="GloballyScoped" />  Example:  select * from master.dbo.sysprocesses select * from master.sys.sysprocesses select * from sysprocesses  msdb references are always explicit 3-part references  Example:  select job_id from msdb.dbo.sysjobs Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 108. 3- & 4-part Names 108  3-part name usage:  SELECT * FROM [LiteralDBRef].[Schema1].[Table1]  SELECT * FROM [$(DBRef)].[Schema1].[Table1]  4-part name usage:  SELECT * FROM [$(ServerRef)].[$(DBRef)].[Schema1].[Table1]  SELECT * FROM [$(ServerRef)].[LiteralDBRef].[Schema1].[Table1] Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 109. Composition 109  Composite Projects  Schema distributed across multiple database projects  Enable division of schema along security or organizational boundaries  Published as “one” logical database  Referenced objects brought into parent model on build  Controlled by “Include Composite Objects” advanced publish option  Removes the need for separate deployment of composing projects Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 110. Publishing Projects 110  Multi-targeting  Deployment Options Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 111. Multi-Targeting 111  Target version aware:  SQL Server 2005  SQL Server 2008 & SQL Server 2008 R2  SQL Server 2012  SQL Azure  Publish  Direct, via SQL script, or DACPAC snapshots Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 112. Publishing Profiles 112 MSBuild fragment for sharing deployment  settings <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <IncludeCompositeObjects>True</IncludeCompositeObjects> <TargetDatabaseName>DinnerNow</TargetDatabaseName> <DeployScriptFileName>TestSqlProj.sql</DeployScriptFileName> <TargetConnectionString>Data Source=gmf4vyn24r.database.windows.net; User ID=gertd@gmf4vyn24r;Pooling=False</TargetConnectionString> <ProfileVersionNumber>1</ProfileVersionNumber> </PropertyGroup> </Project> Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 113. Deployment Options 113  Options to influence deployment behavior  Ignore*  Deployment validation options  Do not alter Change Data Capture objects  Do not ALTER replicated objects  Verify deployment  Deploy without a safety-net Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 114. 114 Application Life Cycle Integration Team development and central build services Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 115. Application Life Cycle Integration 115  MSBuild Support  Source Code Control Integration  Build Server Integration Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 116. MSBuild Support 116  MSBuild tasks for:  Build  Publish  Note: requires using a publishing profile  T-SQL Static Code Analysis  SSDTBuildUtilities.msi  Redist for MSBuild specific components  http://sqlproj.com/index.php/2012/03/headless-msbuild- support-for-ssdt-sqlproj-projects/ Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 117. Source Code Control Support 117  SQL Server Data Tools works with all Visual Studio Source Code Control (SCC) providers  SQL Server Database Projects fully integrate with SCC, no need to do anything special Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 118. Build Server Integration 118  Building  Use MSBuild  Deploying/publishing  Use MSBuild (requires publish profile)  Use SqlPackage.exe  Suggestion: use answer file, override from command line Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 119. Programmatic and Command 119 Line Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 120. SqlPackage.exe 120  Part of DACFramework.msi (redist)  Location:  %ProgramFiles(x86)%Microsoft SQL Server110DACbin  /Action:  {Extract|DeployReport|DriftReport|Publish|Script}  Supports response file @file  Command line override settings in response file Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 121. DacUnpack.exe 121  C:Program Files (x86)Microsoft SQL Server110DACbin  Explorer file handler for unpacking .DACPAC  Note: not a command line tools Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 122. MSBuild Tasks 122  MSBuild /t:Build | Publish | StaticCodeAnalysis  Target file  C:Program Files (x86)MSBuildMicrosoftVisualStudiov10.0SSDT Microsoft.Data.Tools.Schema.SqlTasks.targets Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 123. MSBuild 123  msbuild /t:build sqlproj-nw.sqlproj  msbuild /t:publish sqlproj-nw.sqlproj /p:SqlPublishProfilePath=sqlproj- nw.publish.xml  msbuild /t:StaticCodeAnalysis sqlproj- nw.sqlproj Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 124. MSBuild Target Definitions 124  PreBuildEvent  BeforePublish  BeforeBuild  PrePublishEvent  AfterBuild  PostPublishEvent  PostBuildEvent  AfterPublish <Target Name="BeforeBuild"> <Target Name="BeforePublish"> <Message Text="BeforeBuild message" /> <Message Text="BeforePublish message" / </Target> > <Target Name="AfterBuild"> </Target> <Message Text="AfterBuild message" /> <Target Name="AfterPublish"> </Target> <Message Text="AfterPublish message" /> Copyright © 2012 Gert Drapers - All Rights Reserved. </Target> 03/29/2012
  • 125. Microsoft.SqlServer.Dac.dll 125  Public API  Implements the common DAC verbs  Deploy, ExportBacpac, Extract, GenerateCreateS cript, GenerateDeployReport, GenerateDeployScr ipt, GeneratedriftReport, ImportBacpac, Register, Unregister, Unpack  C:Program Files (x86)Microsoft SQL erver110DACbinMicrosoft.SqlServer.Dac.dll Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 126. 126 Summary Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 127. SQL Server Data Tools – Summary 127  Developer-focused toolset to author, debug and publish SQL Server & SQL Azure databases  Supports SQL Platform  Free, web updates for SQL Server and SQL Azure releases  Works in concert with other SQL Server tooling (SAMP, SSMS)  Compatible with your development environment  Supports Visual Studio 2010 & Visual Studio 11  Migrates VS2010 database projects Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  • 128. Widescreen Test Pattern (16:9) Aspect Ratio Test (Should appear circular) 4x3 16x9 Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012

Notas do Editor

  1. Developer-focused toolset for building SQL Server &amp; SQL Azure databasesExperiences EnabledConnected DevelopmentProject Based DevelopmentApplication Lifecycle &amp; ToolsFundamentalsDeclarative, model based database developmentIntegrated tools with modern language services Connected and offline with local testingTarget SQL Server and SQL AzureDetecting and managing database drift
  2. SQL Server Object Explorer (SSOX)Modeled after SSMS object explorerModern T-SQL Coding Experience Buffered Declarative Object EditingModel-based with Error DetectionImperative Script ExecutionT-SQL IntelliSenseCode-behind Table DesignerView/Edit/Script Data (incl. copy/paste)Execute/Debug T-SQL Procedures, Functions
  3. Database definition managed in a Visual Studio projectMulti-target SQL Server {2005, 2008, 2008R2, 2012, Azure}Advanced Language Services for T-SQLGo To Definition/Find All References/RefactoringF5 debugging with LocalDBVisualize schema differences and migrate changesPublish direct to database or via SQL script or DACPACIntegrated database drift detectionPoint-in-time SnapshotDrag &amp; Drop import from SQL Server Object ExplorerApplication Lifecycle &amp; ToolsMSBuild tasks for:BuildPublishT-SQL Static Code AnalysisMSBuild in a redist (SSDTBuildUtilities.msi)Database projects in build server environment (like Team Build) without installing full VS on build serverSSDT Integrates with all standard VS SCCS providersDACFX v3Schema ComparePublish
  4. Publishing your Database ChangesTarget version aware:SQL Server 2005SQL Server 2008 &amp; SQL Server 2008 R2SQL Server 2012SQL AzurePublish Direct, via SQL script, or DACPAC snapshots
  5. DAC Framework v3.0 (DACFX)DAC FrameworkDACFX is the core SQL redist providing modeling, reverse engineering and deployment pipeline capabilitiesv3.0 supports the full domain of SQL Server 2005, 2008/R2, 2012, and SQL AzureManaged Public APIExposes verbs for DACPAC and BACPAC operationsCommand-line tool (SqlPackage.exe)Exposes DACPAC verbs, project publishDACUnpack.exeWindows file handler for unpacking DACPAC to diskDACFX ClientsSSMS, SSDT, SAMP, I&amp;E, VS Web and DB Publishing
  6. SQL Server Data Tools – SummaryDeveloper-focused toolset to author, debug and publish SQL Server &amp; SQL Azure databasesSupports SQL PlatformFree, web updates for SQL Server and SQL Azure releasesWorks in concert with other SQL Server tooling (SAMP, SSMS)Compatible with your development environmentSupports Visual Studio 2010 &amp; Visual Studio 11Migrates VS2010 database projects (*.dbproj)
  7. Schema Compare is an incredibly useful tool, providing a visual head over SSDT’s model differencing and update engine. It can be used to compare any combination of database, project or dacpac, and allows selective update of the target schema (via an update script in the case of a dacpac). We’ve made some significant changes to the tool for the RTW release, improving its look and feel, particularly to make it easier to digest and process comparison results. This post describes many of Schema Compare&apos;s key features – some of which surfaced in CTP4 – with a screen shot at the bottom that highlights several of them.First, the visual comparison ‘language’ of the results grid:Differences-Only by Default: By default the grid contains differences only (with empty folders removed) – if there is only one difference you will see just one item. And the grid always contains all the actions resulting from the comparison – while you can hide an action temporarily within a contracted group it is always present in the grid and will apply to the update or script unless you exclude it by unchecking the action.Equal Objects filter:A toolbar button adds equal objects to the grid. Enabling this is useful if you want to review, for example, unchanged columns alongside the changed columns in a table. Unsupported Actions filter: You can also choose to see unsupported actions – these result from differences for which there is no supported action that can be taken on the target. These typically result from differences in server objects or built-in types between schema versions.Action Icons: Actions (Add, Change, and Delete) are visualized using icons, making it easier to absorb a set of changes at a glance. The checkbox alongside an icon indicates if the action will be included in the update or generated script. If there is no icon the item will not be included in an update or script.Grayed Items: Items that do not contribute to the update are grayed – excluded actions, unsupported actions and equal objects are all grayed. Folders are grayed when all their contents are grayed making it easy to see when a group of differences have all been excluded without you needing to drill in.Grouping: By default, items are grouped by action so you can quickly assess what changes will be made on update. You can also group the results by object type or by schema. You can expand or collapse a group to temporarily hide detail, and you can exclude all or include all objects in a group.Refactor Highlighting: Schema Compare processes the refactor log if present when targeting a database. Refactoring is indicated in the grid as a change action with the source name bolded to highlight the new schema and/or name. Refactoring will cause objects to be renamed in the database. Refactoring sometimes also shows up as a second order effect on other objects that SQL Server will modify when applying the rename. These will not be marked as actions in the grid as you cannot exclude them, but you will see the changed script if you select the affected object. Probably the biggest set of changes affects the script difference pane. While the grid provides a great overview, to see all changes to an object in the grid you have to fully expand it, which, can quickly clutter the view if you&apos;re reviewing many objects. To address this we’ve focused more attention on the script differencing experience – after all, you are writing and editing object scripts to begin with. Changes include:Expanded Object Scripts: The script difference pane now shows the combined scripts for an object and its hierarchical children. This gives a complete picture of all the changes affecting an object in one easy-to-scan place. To complement this, the Next and Previous buttons step between top-level objects only. Together, these two changes can dramatically simplify scanning through the results of a comparison. Enhanced Script Differencing: The script difference algorithm now treats child objects as discrete entities, more effectively highlighting those that have been added, deleted or changed. The color scheme is now more subtle and better reinforces the direction of changes. And remember that you can expand the script pane or swap it to the top – so you can easily optimize the layout to better focus on reviewing scripts.The screen shot below highlights many of these improvements.
  8. SqlPackage: Command-line tool for creating and deploying SQL Server databases and DACPAC packages.Copyright (c) Microsoft Corporation. All rights reserved.Help for dynamic property usage./@&lt;file&gt;:&lt;string&gt; Read response file for more options./help:[True|False] (short form /?)Help for command actions./Action:{Extract|DeployReport|DriftReport|Publish|Script} Specifies the action to be performed. (short form /a)/OutputPath:&lt;string&gt; Specifies the file path where the output files are generated. (short form /op)/OverwriteFiles:[True|False] Specifies if sqlpackage.exe should overwrite existing files. Specifying false causes sqlpackage.exe to abort action if an existing file is encountered. Default value is True. (short form /of)/Profile:&lt;string&gt; Specifies the file path to a DAC Publish Profile. The profile defines a collection of properties and variables to use when generating outputs. (short form /pr)/Properties:{PropertyName}={Value} Specifies a name value pair for an action specific property; {PropertyName}={Value}. Refer to the help for a specific action to see that action&apos;s property names. Example: sqlpackage.exe /Action:Publish /?. (short form /p)/Quiet:[True|False] Specifies whether detailed feedback is suppressed. Defaults to False. (short form /q)/SourceConnectionString:&lt;string&gt; Specifies a valid SQL Server/Azure connection string to the source database. If this parameter is specified it shall be used exclusively of all other source parameters. (short form /scs)/SourceDatabaseName:&lt;string&gt; Defines the name of the source database. (short form /sdn)/SourceEncryptConnection:[True|False] Specifies if SQL encryption should be used for the source database connection. (short form /sec)/SourceFile:&lt;string&gt; Specifies a source file to be used as the source of action instead of a database. If this parameter is used, no other source parameter shall be valid. (short form /sf)/SourcePassword:&lt;string&gt; For SQL Server auth scenarios, defines the password to use to access the source database. (short form /sp)/SourceServerName:&lt;string&gt; Defines the name of the server hosting the source database. (short form /ssn)/SourceTimeout:&lt;int&gt; Specifies the timeout for establishing a connection to the source database in seconds. (short form /st)/SourceTrustServerCertificate:[True|False] Specifies whether to use SSL to encrypt the source database connection and bypass walking the certificate chain to validate trust. (short form /stsc)/SourceUser:&lt;string&gt; For SQL Server auth scenarios, defines the SQL Server user to use to access the source database. (short form /su)/TargetConnectionString:&lt;string&gt; Specifies a valid SQL Server/Azure connection string to the target database. If this parameter is specified it shall be used exclusively of all other target parameters. (short form /tcs)/TargetDatabaseName:&lt;string&gt; Specifies an override for the name of the database that is the target of sqlpackage.exe Action. (short form /tdn)/TargetEncryptConnection:[True|False] Specifies if SQL encryption should be used for the target database connection. (short form /tec)/TargetFile:&lt;string&gt; Specifies a target file (i.e., a .dacpac files) to be used as the target of action instead of a database. If this parameter is used, no other target parameter shall be valid. This parameter shall be invalid for actions that only support database targets. (short form /tf)/TargetPassword:&lt;string&gt; For SQL Server auth scenarios, defines the password to use to access the target database. (short form /tp)/TargetServerName:&lt;string&gt; Defines the name of the server hosting the target database. (short form /tsn)/TargetTimeout:&lt;int&gt; Specifies the timeout for establishing a connection to the target database in seconds. (short form /tt)/TargetTrustServerCertificate:[True|False] Specifies whether to use SSL to encrypt the target database connection and bypass walking the certificate chain to validate trust. (short form /ttsc)/TargetUser:&lt;string&gt; For SQL Server auth scenarios, defines the SQL Server user to use to access the target database. (short form /tu)/Variables:{PropertyName}={Value} Specifies a name value pair for an action specific variable; {VariableName}={Value}. The DACPAC file contains the list of valid SQLCMD variables. An error will result if a value is not provided for every variable. (short form /v)