{"id":492,"date":"2012-05-10T11:38:00","date_gmt":"2012-05-10T11:38:00","guid":{"rendered":"\/blogs\/bobb\/post\/Scripting-SQL-Server-databases-sans-SMO.aspx"},"modified":"2012-05-10T11:38:00","modified_gmt":"2012-05-10T11:38:00","slug":"scripting-sql-server-databases-sans-smo-scripter","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/","title":{"rendered":"Scripting SQL Server databases sans SMO Scripter"},"content":{"rendered":"<p>\nI can script out a database schema (and optionally data) from SQL Server databases. Any version from 2005 and beyond, as well as SQL Azure Database.&nbsp;And most all instance level objects.&nbsp;&nbsp;And I&#39;m not the SMO scripter object. Or a DBA. Who am I?\n<\/p>\n<p>\nI would be DACFx 3.0. And I can do some things (unlike SMO scripter, or a busy DBA) like script out deltas (schema only), given any two databases or DACPACs. Or&nbsp;any combination of SSDT&nbsp;project,&nbsp;database, and DACPAC.&nbsp;\n<\/p>\n<p>\nWhen DAC (that&#39;s data-tier applications, not dedicated administrator connection) was introduced back around SQL Server 2008 R2, there were a subset of &quot;most likely candidate&quot; database objects it could script. This increased&nbsp;over time to include all SQL Azure database objects.&nbsp;But in DACFx 3.0, which appears in SSMS 2012, SSDT (along with&nbsp;its command-line brother sqlpackage.exe), and soon the Azure portal, there is almost full-fidelity&nbsp;up to&nbsp;SQL Server 2012. There are still some rough edges being worked on (along with enhancements), both in the functionality and in the integration with SSMS, as you might expect.\n<\/p>\n<p>\nSSMS and SQL Server&#39;s PowerShell provider are both built with SMO, and SMO&#39;s functionality roughly follows what SSMS supports (e.g. before SMO 2012 there was no SSMS\/SMO support for extended events; now there is, in both places). SMO is much, much more granular in its API&#8230; think &quot;almost every SSMS dialog is built over SMO&quot;. DACFx providers a discrete set of&nbsp;(less than&nbsp;10)&nbsp;utility functions. But in SSMS 2008 R2, 2008 R2 SP1, and 2012, DACFx makes its presence felt. For example in SSMS 2012, we have, in SSMS Object Explorer:<br \/>\n&nbsp; <br \/>\nDatabases Tab:<br \/>\n&nbsp;&nbsp;&nbsp; Deploy (from DACPAC)<br \/>\n&nbsp;&nbsp;&nbsp; Import (from BACPAC)<br \/>\nIndividual Databases\/Tasks:<br \/>\n&nbsp;&nbsp;&nbsp; Extract (to DACPAC)<br \/>\n&nbsp;&nbsp;&nbsp; Deploy Database to Azure (Migrate via BACPAC)<br \/>\n&nbsp;&nbsp;&nbsp; Export (to BACPAC)<br \/>\n&nbsp;&nbsp;&nbsp; Register (to MSDB, to master on SQL Azure)<br \/>\n&nbsp;&nbsp;&nbsp; Upgrade (existing registration and schema)<br \/>\n&nbsp;&nbsp;&nbsp; Unregister\n<\/p>\n<p>\nIn SSMS, these functions are fairly rigid, i.e. there aren&#39;t many options, failure to comply with the &quot;default options&quot; can cause failure. But with SQLPackage.exe and SSDT and the DACFx API, a plethora of options exist (albeit not as many as SMO scripter, but some of scripter&#39;s options are for code formatting). These options live in the DacDeployOptions and DacExtractOptions classes in the API (that is Microsoft.SqlServer.Dac.dll) and are exposed as command-line switches in SQLPackage.exe or properties in the SSDT project properties page. And documented in the SQL Server documentation.&nbsp;\n<\/p>\n<p>\nIf you don&#39;t want to install SSDT on your machine, you can download DACFx 3.0 as part of the <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?amp;amp;displaylang=en&amp;id=29065\">SQL Server 2012 Feature Pack<\/a>. It&#39;s called &quot;Microsoft&reg; SQL Server&reg; 2012 Data-Tier Application Framework&quot;.\n<\/p>\n<p>\nMore to come&#8230;\n<\/p>\n<p>\n@bobbeauch<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I can script out a database schema (and optionally data) from SQL Server databases. Any version from 2005 and beyond, as well as SQL Azure Database.&nbsp;And most all instance level objects.&nbsp;&nbsp;And I&#39;m not the SMO scripter object. Or a DBA. Who am I? I would be DACFx 3.0. And I can do some things (unlike [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,13,31],"tags":[],"class_list":["post-492","post","type-post","status-publish","format-standard","hentry","category-sql-azure-database","category-data-tier-applications-dac","category-sql-server-2012"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Scripting SQL Server databases sans SMO Scripter - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scripting SQL Server databases sans SMO Scripter - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"I can script out a database schema (and optionally data) from SQL Server databases. Any version from 2005 and beyond, as well as SQL Azure Database.&nbsp;And most all instance level objects.&nbsp;&nbsp;And I&#039;m not the SMO scripter object. Or a DBA. Who am I? I would be DACFx 3.0. And I can do some things (unlike [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2012-05-10T11:38:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/\",\"name\":\"Scripting SQL Server databases sans SMO Scripter - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2012-05-10T11:38:00+00:00\",\"dateModified\":\"2012-05-10T11:38:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Azure SQL Database\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-azure-database\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Scripting SQL Server databases sans SMO Scripter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Scripting SQL Server databases sans SMO Scripter - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/","og_locale":"en_US","og_type":"article","og_title":"Scripting SQL Server databases sans SMO Scripter - Bob Beauchemin","og_description":"I can script out a database schema (and optionally data) from SQL Server databases. Any version from 2005 and beyond, as well as SQL Azure Database.&nbsp;And most all instance level objects.&nbsp;&nbsp;And I&#39;m not the SMO scripter object. Or a DBA. Who am I? I would be DACFx 3.0. And I can do some things (unlike [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/","og_site_name":"Bob Beauchemin","article_published_time":"2012-05-10T11:38:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/","name":"Scripting SQL Server databases sans SMO Scripter - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2012-05-10T11:38:00+00:00","dateModified":"2012-05-10T11:38:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/scripting-sql-server-databases-sans-smo-scripter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"Azure SQL Database","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-azure-database\/"},{"@type":"ListItem","position":3,"name":"Scripting SQL Server databases sans SMO Scripter"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=492"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/492\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}