Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
1 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
SQL Saturday #176Pordenone, ItalySQL Server Data Tools 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
#sqlsat1763 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
Marco Parenzan  .NET Developer, SQL User  1nn0va Speaker (www.innovazionefvg.net)  Trainer and consultant on applicatio...
The Developer‟s experience    DATABASE DEVELOPMENT5 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
Database Development  Often not integrated into application life cycle   management and processes  What is a database de...
The premise    IMPERATIVE DATABASE    DEVELOPMENT7 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
Database Development Challenges  Databases are inherently stateful        Focus is on ALTER instead of CREATE        De...
Simple Schema Versioning Example-- version 1CREATE TABLE dbo.Speakers( SpeakerId INT NOT NULL, FirstName NVARCHAR(64) NOT ...
Imperative   Imperative scripts hard codes knowledge about:         The state of the target system:                Pres...
Imperative Versioning      -- version 1 Add table dbo.Auction      IF OBJECT_ID (Ndbo.Auction, NU) IS NULL      BEGIN  ...
Missing/Manual   Object Dependencies   Intercept errors before deployment   Don‟t loose data   Sync DB   Managing dif...
The foundation      DECLARATIVE DATABASE      DEVELOPMENT13 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
Declarative   Define what you want in the form of a model         Think about a table without thinking about the        ...
Declarative Versioning                    -- version 1                    CREATE TABLE dbo.Auction                        ...
Model as the starting point “blueprint”   Deployment/publish, start by comparing the    current state of the target with ...
Declarative Schema Deployment17                        Source                                      Target                 ...
Imperative vs. Declarative   Manual vs. generated / programmatic   Point in time vs. always current   Sequential vs. di...
Model Based          .SQL                                   SqlScript               Schema                              Pa...
Script Fundamentals   Requirement to be    able to round trip DSL                                                A    art...
ScriptDom   SQL Server 2012 managed    parser         Supports SQL Server 2005+   Class TSqlXXXParser         XXX = [8...
Basic ScriptDom loop         static void Main(string[] args)         {              bool initialQuotedIdentifiers = false;...
23      SQL SERVER DATA TOOLS      OVERVIEW23 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
History of the “DataDude” Project   Project funded April 2005   Project started July 1st 2005   Visual Studio 2005 Team...
Database Project Evolution of VS database project    We have more things We don‟t have      Data generation      Unit...
DataDude Vs SSDT Comparison (1)  http://blogs.msdn.com/b/ssdt/archive/2011/11/21/sql-server-data-tools-ctp4-vs-  vs2010-da...
DataDude Vs SSDT Comparison (2)  http://blogs.msdn.com/b/ssdt/archive/2011/11/21/sql-server-data-tools-ctp4-vs-  vs2010-da...
Supported OS Platforms      Windows Vista SP2+      Windows 7 SP1+      Windows Server 2008 SP+      Windows Server 20...
Availability   Visual Studio 2010 Integrated Shell         SQL-CLR requires Visual Studio 2010 Standard   Visual Studio...
Features of SQL Server Data Tools30 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy                                 ...
31      CONNECTED DEVELOPMENT31 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
Connected Development   SQL Server Object Explorer (SSOX)            T-SQL Editor/Debugger/IntelliSense (New Query)     ...
SQL Server Object Explorer (SSOX)   The SQL Server navigation tool window         Modeled after the SSMS Object Explorer...
T-SQL Editor/Debugger/IntelliSense   T-SQL IntelliSense         SQL Server 2005+ incl. SQL Azure   Result to Grid | Tex...
Power-Buffer/Table Designer   Declarative deferred online schema management         Brings “project-oriented” features t...
Data Editor   View and Edit Data via grid editor   Copy-Paste support   Generate as INSERT to file or query window36 | ...
Execute Procedure/Function   Dialog based input for parameter collection         Generates SQL script for execution/debu...
38      PROJECT BASED      DEVELOPMENT38 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
Creating and Importing   Single project template         VSDB note:                No distinction between server or use...
Folder Structure   Options on import:           None           Schema           Object type           SchemaObject ty...
Project Directory Guidelines…   Do not host more then one table inside script    file         Table designer will not se...
Additional Language Services   Projects enable additional language services         Go To Definition         Find All R...
T-SQL Static Code Analysis   Rule set   Suppression         File level         Project level   MSBuild support43 | 17...
Multi-Targeting   Target version aware:           SQL Server 2005           SQL Server 2008 & SQL Server 2008 R2       ...
Isolated Sandbox F5 – Run by default configure to use the  LocalDB instance associated with the project   Data Source=(l...
SQL Server 2012 Express LocalDB      Simplify embedded usage of SQL Server           Simple installation           Zero...
Build Time Validation   Build validates the complete model         Platform specific validation                Example ...
Build Actions   Build - This script will be interpreted as T-SQL (or an XML    Schema in the case of XML Schema Collectio...
Pre & Post Deployment Scripts   Can be used for any “arbitrary” SQL actions that you    need to perform “before” and “aft...
Database References   3-part name usage:         SELECT * FROM          [LiteralDBRef].[Schema1].[Table1]         SELEC...
Project Deployment   Build serializes the model in to model.xml    stream inside .dacpac file51 | 17/11/2012 |   SQL Satu...
52           Schema Deployment           SQL SERVER DATA TOOLS           03/29/2012Copyright © 2012 Gert Drapers - All Rig...
What is a Data-Tier Application          (dacpac)?           Data-Tier Application Component (DAC)                   SQL...
DACFX Packages           .dacpac - Packaged Schema representing the declarative model            of the database         ...
DAC Framework v3.0 (DACFX)             Core SQL Server redist component providing              modeling, reverse engineer...
Database Schema Snapshots   Point-in-time representation of schema model         Model must be “error-free” state       ...
Schema Compare   Performs a model comparison between:          Databases          Projects          DACPAC files (snap...
Schema Definition                                          Script                                                         ...
Deployment & Schema Compare Script                                                                                        ...
Schema Compare                      Next and Previous move between top-                                           level ob...
Schema Compare61 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
Deployment Options  Options to influence   deployment behavior        Ignore*  Deployment validation   options        ...
63           SQL CLR           SQL SERVER DATA TOOLS           03/29/2012Copyright © 2012 Gert Drapers - All Rights Reserv...
SQL-CLR Support   Embedded C# or VB.NET code artifacts         Deployed as SQL-CLR objects   Binary assembly deployment...
CLR Needs   SQL Server CLR usage         Geographical support   Your needs         Web communication         Custom f...
66           SQL AZURE           SQL SERVER DATA TOOLS           03/29/2012Copyright © 2012 Gert Drapers - All Rights Rese...
SQL Azure   It‟s Cloud Computing!   SQL Server e SQL Azure sono diversi         Diverse esigenze   Connected developme...
Conclusions      SQL SERVER DATA TOOLS68 | 17/11/2012 |   SQL Saturday #176 – Pordenone, Italy
   Already third party tools   First release         Many step forward         Some step back (compared to DataDude)6...
Conclusions      Modeling infrastructure      One development environment      More checks over actions      Use targe...
Resources   Articles         MSDN Magazine Sept 2011 The "Juneau"          Database Project   SQL Server Data Tools Onl...
References      twitter: @marco_parenzan      email: marco.parenzan@libero.it      blog: http://codeisvalue.wordpress.c...
GRAZIE!           Commenta la sessione che hai                                              appena seguito su Twitter     ...
Upcoming SlideShare
Loading in …5
×

SQL Server Data Tools

1,708 views

Published on

Nella creazione di applicazioni, non abbiamo mai avuto a disposizione un ambiente integrato, dedicato allo sviluppatore per la progettazione e il deployment di un Database, per la scrittura di codice SQL. Oggi questa lacuna è stata colmata dall'introduzione degli SQL Server Data Tools: grazie ad un apposito template per Visual Studio 2010 e 2012, è possibile gestire un progetto SQL, come un progetto di una applicazione desktop o di una applicazione web. Vediamo insieme cosa possiamo fare con questi strumenti.

Published in: Technology
  • Be the first to comment

SQL Server Data Tools

  1. 1. 1 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  2. 2. SQL Saturday #176Pordenone, ItalySQL Server Data Tools 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  3. 3. #sqlsat1763 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  4. 4. Marco Parenzan  .NET Developer, SQL User  1nn0va Speaker (www.innovazionefvg.net)  Trainer and consultant on application development in companies and in University (of Trieste)  Head of Development in CGN S.P.A. (www.cgn.it)4 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  5. 5. The Developer‟s experience DATABASE DEVELOPMENT5 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  6. 6. Database Development  Often not integrated into application life cycle management and processes  What is a database development experience?  Install SSMS into developer machine….  It‟s an «admin» tool  Outside Visual Studio (it‟s Visual Studio yes)  Third party tools…  What does »deployment» means?6 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  7. 7. The premise IMPERATIVE DATABASE DEVELOPMENT7 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  8. 8. Database Development Challenges  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  Targeting different SQL Server and SQL Azure versions8 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  9. 9. Simple Schema Versioning Example-- version 1CREATE TABLE dbo.Speakers( SpeakerId INT NOT NULL, FirstName NVARCHAR(64) NOT NULL, LastName NVARCHAR(64) NOT NULL,)-- version 2 -- version 3ALTER TABLE dbo.Speakers ALTER TABLE dbo.SpeakersWITH CHECK ADD CONSTRAINT WITH CHECKSpeaker_PK ADD CONSTRAINT Speaker_PK UNIQUE (LastName, FirstName)V1 V2 V3 Revision History 9 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  10. 10. Imperative  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  There are third party tools10 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  11. 11. Imperative Versioning  -- version 1 Add table dbo.Auction  IF OBJECT_ID (Ndbo.Auction, NU) 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)  END11 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  12. 12. Missing/Manual Object Dependencies Intercept errors before deployment Don‟t loose data Sync DB Managing different versions
  13. 13. The foundation DECLARATIVE DATABASE DEVELOPMENT13 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  14. 14. Declarative  Define what you want in the form of a model  Think about a table without thinking about the specific SQL  Fill the model using a DSL (domain specific language)  T-SQL  Use the model as the starting point “blueprint” for all operations14 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  15. 15. Declarative Versioning -- version 1 CREATE TABLE dbo.Auction -- version 2 ( CREATE TABLE dbo.Auction id ( INT NOT NULL,3 -- version name id CREATE NOT NOTdbo.Auction TABLE NULL, VARCHAR(25) NULL PRIMARY KEY, INT ( start DATETIME NULL, NOT NULL, name VARCHAR(25) len start NULL INT NOT NULL PRIMARY KEY, INTidDATETIME NULL, ) name VARCHAR(25) NOT NULL UNIQUE, len INT NULL start DATETIME NULL, ) len INT NULL )V1 V2 V3 Revision History15 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  16. 16. Model as the starting point “blueprint”  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 state16 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  17. 17. Declarative Schema Deployment17 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 DB17 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  18. 18. Imperative vs. Declarative  Manual vs. generated / programmatic  Point in time vs. always current  Sequential vs. differential18 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  19. 19. Model Based .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)  Validation19 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  20. 20. Script Fundamentals  Requirement to be able to round trip DSL A artifacts S T  Script  Model  SQL script Parse Script Parser Script fragment T-SQL Fragment  Script fragment Script Gen  SQL script  Script fragment is AST Script Script Gen T-SQL Fragment (Abstract Syntax Tree)20 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  21. 21. ScriptDom  SQL Server 2012 managed parser  Supports SQL Server 2005+  Class TSqlXXXParser  XXX = [80, 90, 100, 110]  SQLDom.msi (redist x86/x64)  Microsoft.SqlServer.TransactSql.S criptDom.dll  C:Program Files (x86)Microsoft SQL Server110SDK AssembliesMicrosoft.SqlServer.Tra nsactSql.ScriptDom.dll  GAC21 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  22. 22. Basic ScriptDom loop 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); }22 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  23. 23. 23 SQL SERVER DATA TOOLS OVERVIEW23 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  24. 24. History of the “DataDude” Project  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 Tools24 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  25. 25. Database Project Evolution of VS database project  We have more things We don‟t have  Data generation  Unit testing  Data compare  Use a DB Project for this  http://social.msdn.microsoft.com/Forums/en-US/ssdt/thread/33664902- a4e2-415a-ad4e-a480fbc56158/  Not available in Professional or Express Edition Migration  http://geekswithblogs.net/80n/archive/2012/09/11/vsdb-to-ssdt- series--introduction.aspx Comparison
  26. 26. DataDude Vs SSDT Comparison (1) http://blogs.msdn.com/b/ssdt/archive/2011/11/21/sql-server-data-tools-ctp4-vs- vs2010-database-projects.aspx26 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  27. 27. DataDude Vs SSDT Comparison (2) http://blogs.msdn.com/b/ssdt/archive/2011/11/21/sql-server-data-tools-ctp4-vs- vs2010-database-projects.aspx27 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  28. 28. Supported OS Platforms  Windows Vista SP2+  Windows 7 SP1+  Windows Server 2008 SP+  Windows Server 2008 R2 SP1+  Note: this is different then the Visual Studio 2010 platforms28 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  29. 29. Availability  Visual Studio 2010 Integrated Shell  SQL-CLR requires Visual Studio 2010 Standard  Visual Studio 2010 SP1  Visual Studio 2012  SQL Server 201229 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  30. 30. Features of SQL Server Data Tools30 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy 03/29/2012
  31. 31. 31 CONNECTED DEVELOPMENT31 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  32. 32. Connected Development  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 Compare32 | 03/29/2012 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  33. 33. SQL Server Object Explorer (SSOX)  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 server33 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  34. 34. T-SQL Editor/Debugger/IntelliSense  T-SQL IntelliSense  SQL Server 2005+ incl. SQL Azure  Result to Grid | Text | File  Execution modes  Execute  Execute with debugger  Reusable debug script generation34 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  35. 35. Power-Buffer/Table Designer  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)35 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  36. 36. Data Editor  View and Edit Data via grid editor  Copy-Paste support  Generate as INSERT to file or query window36 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  37. 37. Execute Procedure/Function  Dialog based input for parameter collection  Generates SQL script for execution/debugging37 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  38. 38. 38 PROJECT BASED DEVELOPMENT38 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  39. 39. Creating and Importing  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 database39 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  40. 40. Folder Structure  Options on import:  None  Schema  Object type  SchemaObject type40 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  41. 41. Project Directory Guidelines…  Do not host more then one table inside script file  Table designer will not see additional tables inside script41 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  42. 42. Additional Language Services  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 objects42 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  43. 43. T-SQL Static Code Analysis  Rule set  Suppression  File level  Project level  MSBuild support43 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  44. 44. Multi-Targeting  Target version aware:  SQL Server 2005  SQL Server 2008 & SQL Server 2008 R2  SQL Server 2012  SQL Azure44 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  45. 45. Isolated Sandbox 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
  46. 46. SQL Server 2012 Express LocalDB  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).aspx46 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  47. 47. Build Time Validation  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  Pre & Post Deployment scripts  Build validates syntactical correctness of pre- and post- deployment scripts using the SQLCMD variables47 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  48. 48. Build Actions  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 None48 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  49. 49. Pre & Post Deployment Scripts  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/idempoten t-scripts-required.aspx49 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  50. 50. Database References  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]50 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  51. 51. Project Deployment  Build serializes the model in to model.xml stream inside .dacpac file51 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  52. 52. 52 Schema Deployment SQL SERVER DATA TOOLS 03/29/2012Copyright © 2012 Gert Drapers - All Rights Reserved.
  53. 53. What is a Data-Tier Application (dacpac)?  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 53Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  54. 54. DACFX Packages  .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) 54Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  55. 55. DAC Framework v3.0 (DACFX)  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 55Copyright © 2012 Gert Drapers - All Rights Reserved. 03/29/2012
  56. 56. Database Schema Snapshots  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 changes56 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  57. 57. Schema Compare  Performs a model comparison between:  Databases  Projects  DACPAC files (snapshots, build outputs, extracts)  Supports:  Refactoring log  SQLCMD variables57 | 03/29/2012 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  58. 58. Schema Definition Script Model Builder Fragment Source DB Scaffolding Schema Model Schema Model Deserializer Package58 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  59. 59. Deployment & Schema Compare Script Script Model Model Builder BuilderFragment Fragment Source Target DB Scaffolding Schema Schema Scaffolding DB Model Model ModelSchema Model Compare Model Schema Deserializer DeserializerPackage Package Diff List Plan Diff Optimizer Visualizer Deploy Plan 59 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy Script Generator
  60. 60. Schema Compare Next and Previous move between top- level objects, no longer expand the tree. Simpler set of columns are aligned around the central action column echoes alignment of schemas above 60Group-by Action is the Samedefault column order is used for all groupings; cleaner and easier toSchema no longer parseused as a parent for regardless oftop-level objects; only groupingshown when changedImproved script diff’algorithm for tablesemphasizes columnsas unit of change.Gives much improvedalignment. Alsoimproved look 60 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  61. 61. Schema Compare61 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  62. 62. Deployment Options  Options to influence deployment behavior  Ignore*  Deployment validation options  Do not alter Change Data Capture objects  Do not ALTER replicated objects  Verify deployment Copyright © 2012 Gert Drapers - All Rights62 03/29/2012 Reserved.
  63. 63. 63 SQL CLR SQL SERVER DATA TOOLS 03/29/2012Copyright © 2012 Gert Drapers - All Rights Reserved.
  64. 64. SQL-CLR Support  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];64 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  65. 65. CLR Needs  SQL Server CLR usage  Geographical support  Your needs  Web communication  Custom function  String management  Aggregate functions  «extreme calculus» in sp  Don‟t abuse65 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  66. 66. 66 SQL AZURE SQL SERVER DATA TOOLS 03/29/2012Copyright © 2012 Gert Drapers - All Rights Reserved.
  67. 67. SQL Azure  It‟s Cloud Computing!  SQL Server e SQL Azure sono diversi  Diverse esigenze  Connected development on SQL Azure  Change targetFix & Build67 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  68. 68. Conclusions SQL SERVER DATA TOOLS68 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  69. 69.   Already third party tools  First release  Many step forward  Some step back (compared to DataDude)69 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  70. 70. Conclusions  Modeling infrastructure  One development environment  More checks over actions  Use targets  A tool for SQL Azure  Debug and schema deployment  Go under TFS70 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  71. 71. Resources  Articles  MSDN Magazine Sept 2011 The "Juneau" Database Project  SQL Server Data Tools Online Installation  http://msdn.microsoft.com/data/tools  Team Blog  http://blogs.msdn.com/b/ssdt/71 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  72. 72. References  twitter: @marco_parenzan  email: marco.parenzan@libero.it  blog: http://codeisvalue.wordpress.com/  facebook: http://www.facebook.com/parenzan.marco  linkedin: http://it.linkedin.com/in/marcoparenzan  slideshare: http://www.slideshare.net/marco.parenzan/72 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy
  73. 73. GRAZIE! Commenta la sessione che hai appena seguito su Twitter #sqlsat17673 | 17/11/2012 | SQL Saturday #176 – Pordenone, Italy

×