<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tag 'Datadude'</title><link>http://www2.sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Datadude&amp;orTags=0</link><description>Search results matching tag 'Datadude'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Considerations when starting a new SSDT database project</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2013/03/21/considerations-when-starting-a-new-ssdt-database-project.aspx</link><pubDate>Thu, 21 Mar 2013 10:58:03 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:48327</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;As you may have realised from much of my blogging over the past year or so I’m an advocate of using SSDT database projects for building database solutions on SQL Server. I have been using SSDT database projects a lot in that time and have come up with a checklist of things to consider when starting a new SSDT database project and I’ll be detailing that checklist below. I strongly advise you to consider making decisions about these items before you even write a scrap of code as invariably it will be more difficult to change later, especially if you have already deployed your database.&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;In no particular order here is my checklist:&lt;/p&gt;  &lt;h3&gt;Folder Structure&lt;/h3&gt;  &lt;p&gt;By default SSDT will not provide a folder structure for new projects in which to store all your script files so you might want to consider setting one up yourself. I recommend not trying to create a large hierarchy of folders to start with as this will evolve as you go about building your database. Here’s a simple starter for ten:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_2ADBA6CA.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_174E4729.png" width="212" height="138" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Filegroups&lt;/h3&gt;  &lt;p&gt;If you don’t understand the importance of filegroups then read Thomas Larock’s recent blog post &lt;a href="http://thomaslarock.com/2013/01/database-filegroups-just-like-seatbelts-but-with-less-chafing/"&gt;DATABASE FILEGROUPS: JUST LIKE SEATBELTS BUT WITH LESS CHAFING&lt;/a&gt;. Quite often your organisation will stipulate policies for what filegroups you should be using and I highly recommend that you set up filegroups in your database projects to match those policies sooner rather than later. If your organisation does not have any such policies then perhaps think about defining them yourself, Thomas lists a few considerations that may influence your decisions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;separation of system data from user data &lt;/li&gt;    &lt;li&gt;larger indexes may benefit from their own filegroup &lt;/li&gt;    &lt;li&gt;archival of data can benefit from using dedicated filegroups as this will reduce backup maintenance tasks &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If you follow my suggested folder structure above then put your filegroups into the “Storage” folder:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_2852750C.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_75826E97.png" width="183" height="173" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Above all, specify your default filegroup especially as many DBAs won’t be happy about you putting objects into the PRIMARY filegroup (which is the default). This is done by right-clicking on the project and selecting “Properties..” When there hit “Database Settings…” and set your default filegroup on the “Operational” tab:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML1ebb40b8_7FD392F7.png"&gt;&lt;img title="SNAGHTML1ebb40b8" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="SNAGHTML1ebb40b8" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML1ebb40b8_thumb_25C9434E.png" width="405" height="146" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;If you intend to use the filestream feature of SQL Server then you can set the default filestream filegroup here too.&lt;/p&gt;  &lt;h3&gt;Collation&lt;/h3&gt;  &lt;p&gt;If you take only one piece of advice from this blog post make it this: &lt;strong&gt;set your collation before you write a single line of code&lt;/strong&gt; (just trust me on this, OK). You’ll find this in Project Properties-&amp;gt;Project Settings-&amp;gt;Database Settings-&amp;gt;Common&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML1ebc6e3e_4BBEF3A4.png"&gt;&lt;img title="SNAGHTML1ebc6e3e" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="SNAGHTML1ebc6e3e" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML1ebc6e3e_thumb_71B4A3FA.png" width="415" height="160" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Again, find out if your organisation has any guidance on database collation.&lt;/p&gt;  &lt;h3&gt;Specify Target platform&lt;/h3&gt;  &lt;p&gt;SSDT allows you to deploy a project to SQL Server 2005, 2008, 2012 or Azure so it stands to reason that you should specify which you are intending to deploy to. You’ll find this in Project Properties-&amp;gt;Project Settings:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_778F4793.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5AA622BE.png" width="399" height="128" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h3&gt;Default Schema&lt;/h3&gt;  &lt;p&gt;If you follow the premise that “anything that SQL Server picks as the default is probably wrong” then you should probably think about changing the default schema which, by default, will be [dbo]. SSDT will create all new objects in the default schema (unless otherwise specified).&lt;/p&gt;  &lt;p&gt;Generally I’m of the opinion that not accepting SQL Server’s defaults is a good idea if only because it forces you to think about these things and be aware of them; in the case of schemas it forces you to think about security and who should have GRANT or DENY permissions and on what.&lt;/p&gt;  &lt;p&gt;Specify the default schema in Project properties-&amp;gt;Project Settings:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_158D5588.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_791063A7.png" width="428" height="71" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Review other database settings&lt;/h3&gt;  &lt;p&gt;I’ve mentioned the most important database settings that you should look to change however you should also glance over the rest of the defaults that SSDT chooses for you to verify that they are valid for your project. Again, these are in Project Properties-&amp;gt;Project Settings-&amp;gt;Database Settings. a few I’d call out as being especially worthy of your attention are:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Auto update stats (on by default) &lt;/li&gt;    &lt;li&gt;Recovery model (FULL by default) &lt;/li&gt;    &lt;li&gt;Transaction Isolation (RCSI off by default) &lt;/li&gt;    &lt;li&gt;Service broker (disabled by default) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_18530A7B.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_6C360D89.png" width="244" height="240" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_5D1F2EAF.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_42DEC58B.png" width="395" height="404" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_289E5C67.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_12684115.png" width="396" height="403" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Code Analysis&lt;/h3&gt;  &lt;p&gt;SSDT always checks the syntax of your database code, that’s one of the main justifications for using SSDT database projects. However what it does not do (not by default anyway) is check whether the code you write might be considered &lt;em&gt;good &lt;/em&gt;code. That’s what Code Analysis is for, your code gets checked to see if it adheres to well-understood good practices for SQL Server database development. For example, Code Analysis will check for use of “SELECT*” which is generally regarded as a bad thing.&lt;/p&gt;  &lt;p&gt;Code analysis is turned off by default. I recommend that you head into Project Properties-&amp;gt;Code Analysis and turn it on. Moreover I recommend that you check all the boxes under “Treat Warning as Error” – this forces developers to address issues that get raised by Code Analysis.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0D195A64.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_2B839B4D.png" width="437" height="255" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Big Labels&lt;/h3&gt;  &lt;p&gt;Add a banner to your Pre-Deployment script as I describe in &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/09/26/big-label-generator.aspx" target="_blank"&gt;Big label generator&lt;/a&gt;. This may seem rather unnecessary but it takes about 30 seconds and believe me, at some point you’ll be glad you did!&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;img src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_2A99351D.png" width="619" height="334" /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The demo project that I took some of the above screenshots from is downloadable from &lt;a title="http://sdrv.ms/ZW0gNt" href="http://sdrv.ms/ZW0gNt"&gt;http://sdrv.ms/ZW0gNt&lt;/a&gt; and might provide a useful template for your own SSDT database projects.&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;If you have any more suggestions for my checklist please add them to the comments below!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>SSDT database projects were not always going to output T-SQL…</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2013/02/13/ssdt-database-projects-were-not-always-going-to-output-t-sql.aspx</link><pubDate>Wed, 13 Feb 2013 09:15:18 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47693</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;Interesting the stuff you pick up from reading forums…&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;“The BATCH seperators [in SSDT deployment scripts] are used to provide scoping when resolving object shapes. SSDT or VSDB scripts for that matter serve a different purpose, they provide the blueprint of the model you want, and do not represent how it will be used to construct the target site. &lt;strong&gt;We choose TSQL as our DSL, at first we wanted to use a different representation&lt;/strong&gt;, but user research in 2005 told us loud and clear users wanted to use TSQL as their DSL. In order to make the compiler work, we had to impose some simplifications, one is a more frequent use of BATCH seperators to indentify object scopes.”&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;by Gert Drapers (former lead of the SSDT product team) at &lt;/em&gt;&lt;a title="http://social.msdn.microsoft.com/Forums/en-US/ssdt/thread/47d4124b-82cd-48f9-8ba7-c2ae4c73cbcf/" href="http://social.msdn.microsoft.com/Forums/en-US/ssdt/thread/47d4124b-82cd-48f9-8ba7-c2ae4c73cbcf/"&gt;&lt;em&gt;http://social.msdn.microsoft.com/Forums/en-US/ssdt/thread/47d4124b-82cd-48f9-8ba7-c2ae4c73cbcf/&lt;/em&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Personally I’m glad that they chose to use T-SQL as it makes debugging easier but I’d be interested to know what else was on the table!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Which version of SSDT Database Projects do I have installed?</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2013/02/08/which-version-of-ssdt-database-projects-do-i-have-installed.aspx</link><pubDate>Fri, 08 Feb 2013 21:15:52 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47608</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;SQL Server Data Tools (SSDT) is released on a very regular cadence (note that I’m talking about the &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/04/03/ssdt-what-s-in-a-name.aspx" target="_blank"&gt;database projects part of SSDT&lt;/a&gt;, this is nothing to do with SSIS/SSAS/SSRS). Since the first release in &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/03/05/available-today-sql-server-data-tools-rtw.aspx" target="_blank"&gt;March 2012&lt;/a&gt; there have been releases in &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/09/14/now-available-sql-server-data-tools-september-2012-update.aspx" target="_blank"&gt;September 2012&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/11/07/sql-server-data-tools-november-2012-is-now-available.aspx" target="_blank"&gt;November 2012&lt;/a&gt;, &amp;amp; &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/12/13/available-today-ssdt-december-2012.aspx" target="_blank"&gt;December 2012&lt;/a&gt;. I personally have found it difficult to keep track of not only which particular version I am using but also that which are my colleagues are using – quite simply I didn’t know how to discover the current version number. I assumed that the answer would lie within Visual Studio 2012 in the Help-&amp;gt;About Microsoft Visual Studio menu option, when I checked there I saw this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML339e96a2_1BDE30CA.png"&gt;&lt;img title="SNAGHTML339e96a2" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="SNAGHTML339e96a2" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML339e96a2_thumb_286BDDE6.png" width="507" height="333" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;A version number – 11.1.21208.0. What does that mean though? To understand more we have to go to Add/Remove programs:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML42d8efe8_2008088F.png"&gt;&lt;img title="SNAGHTML42d8efe8" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="SNAGHTML42d8efe8" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML42d8efe8_thumb_528B6601.png" width="934" height="275" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are many different items listed there, let’s look at them in turn:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Microsoft SQL Server 2012 Data-Tier App Framework&lt;/strong&gt;. This is fairly self-explanatory if you know what the Data-Tier App Framework (aka DACFx) is. If you don’t, see the notes at the end of this blog post*. The reason that you see two entries in the list above is due to my having the 32bit &amp;amp; 64bit versions installed – the fact that there is no differentiation between the two in the title is a bug. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server 2012 Express LocalDB&lt;/strong&gt;. LocalDB is the small server-less version of SQL Server that now gets deployed with SQL Server proper. LocalDB also gets installed with SSDT if you do not already have it, but you should consider it part of SQL Server itself. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools 2010&lt;/strong&gt;. This was described to me as the “installation chainer” – it is the installation component that manages SSDT and its dependencies. I think of it as the SSDT shell within Visual Studio 2010. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools 2012&lt;/strong&gt;. This was described to me as the “installation chainer” – it is the installation component that manages SSDT and its dependencies. I think of it as the SSDT shell within Visual Studio 2012. Note that the version number is the same as in the Help-&amp;gt;About screenshot at the top of this article – that is because they are one and the same. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools – Database Projects – Web installer entry point&lt;/strong&gt;. A stub project that gets installed when you install SQL Server. Its the SSDT database project entry point. &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;u&gt;&lt;strong&gt;Microsoft SQL Server Data Tools – enu (10.3.21208.0)&lt;/strong&gt; &amp;amp; &lt;strong&gt;Microsoft SQL Server Data Tools – enu (11.1.21208.0)&lt;/strong&gt;. These are the things we’re interested in. These *are* SSDT database projects, for Visual Studio 2010 &amp;amp; Visual Studio 2012 respectively. The version numbers are those for the December 2012 release; note that the build numbers are the same (X.X.21208.X), only the major and minor numbers are different.&lt;/u&gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools Build Utilities – enu (10.3.21208.0)&lt;/strong&gt; &amp;amp; &lt;strong&gt;Microsoft SQL Server Data Tools Build Utilities – enu (11.1.21208.0)&lt;/strong&gt;. Everything you need to do a headless (i.e. without having Visual Studio installed) build/deploy of an SSDT database project. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So at the end of all that we have determined the following version numbers for SSDT database projects are:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2"&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;&lt;strong&gt;Release&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;&lt;strong&gt;Visual Studio 2010 version number&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;&lt;strong&gt;Visual Studio 2012 version number&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;September 2012&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;10.3.20905.0&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;11.1.20905.0&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;November 2012&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;10.3.21101.1&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;11.1.21101.1&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;December 2012&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;10.3.21208.0&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;11.1.21208.0&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;strike&gt;I do not know the version numbers for the March 2012, September 2012 &amp;amp; November 2012 releases (if anyone out there does know please let me know in the comments) however I shall update this blog post for future releases.&lt;/strike&gt; September 2012 and November 2012 releases now added!&lt;/p&gt;  &lt;p&gt;I have requested that any blog post to announce future releases should contain the version numbers. Let’s hope that happens.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;* DACFx is described &lt;a href="http://www.microsoft.com/en-gb/download/details.aspx?id=35756" target="_blank"&gt;here&lt;/a&gt; as:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The Microsoft® SQL Server® 2012 Data-Tier Application Framework (DACFx) is a component which provides application lifecycle services for database development and management for Microsoft® SQL Server® and Windows Azure SQL Databases.      &lt;br /&gt;DacFX supports various database deployment and management scenarios for SQL Server and Windows Azure SQL Databases including extracting/exporting a live database to a DAC package, deploying a DAC package to a new or existing database, and migrating from on-premise SQL Server to Windows Azure. This functionality is exposed via the DACFx managed API. DACFx can target SQL Server 2005 SP4, 2008 SP1, 2008R2, 2012, and Windows Azure SQL Databases. DACFx also provides the command-line utility SqlPackage.exe for creating and deploying .dacpac and .bacpac packages. DACFx supports scenarios provided by SQL Server client tooling including SQL Server Data Tools and SQL Server Management Studio 2012.&lt;/p&gt;&lt;/blockquote&gt;</description></item><item><title>Responses to SSDT questions</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2013/01/11/responses-to-ssdt-questions.aspx</link><pubDate>Fri, 11 Jan 2013 22:22:24 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47124</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;My recent article &lt;a href="http://www.devproconnections.com/article/sql-server-2012/sql-server-2012-data-tools-144829"&gt;Get to Know SQL Server 2012's SQL Server Data Tools&lt;/a&gt; prompted two questions to come to me via email and in the interests of sharing knowledge via search engines I thought I would answer them here rather than by simply replying by email (I hate that so much useful information gets trapped inside closed inboxes).&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Question: How would you handle cases below, our main database has many objects already, we are using redgate source control to keep things under sourcecontrol but ssdt would be awesome.        &lt;br /&gt;Our database has some invalid stored procs etc, unfortunately we do not want to drop them, underlying objects either don't exists or has changed etc         &lt;br /&gt;There are linked servers or code referencing other objects stored in the database         &lt;br /&gt;There are staging table named automatically in the database and we do not want to include them in the project and not drop them or touch them in a deploy &lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;JT: The overall question here seems to be “how do we prevent SSDT from DROPping sprocs and staging tables that are in the target database but are not in the SSDT project?” Fortunately SSDT has an option within it to allow exactly what the questioner requires. When an SSDT project is published one has the option to set some properties relating to that publish. One of the settings is “DROP objects in target but not in project”:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML5751f10_20688721.png"&gt;&lt;img title="SNAGHTML5751f10" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="SNAGHTML5751f10" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML5751f10_thumb_11A9A170.png" width="340" height="484" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;If that option is left unchecked (which is the default) then no objects will get removed from the target database.&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Question: At my previous shop, I done a proof of concept with one of our databases, but never got it implemented as VS2012 (with SSDT) had not been released yet. Well, fast forward 9 or so months, and at my new shop (which is extremely agile) I've been tasked with setting up our db projects with SSDT so for the immediate short term goals/objectives we can;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Allow new or existing developers to be able to easily get the latest databases from source control downloaded from TFS, built and deployed onto our local sandbox db environments. This ideally will be done via a powershell script or something of the sort. &lt;/font&gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;font color="#c0504d"&gt;&lt;em&gt;Be able to employ C.I. so that every night a database deployment is done to our system test servers.&lt;/em&gt; &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;3 days into it, and I've wrestled with 3 of our databases, reverse engineering them into TFS and getting them built etc. My question is, what are the best practices or guidelines for;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Allowing only Windows authentication for the local deploys to the sandbox environment. i.e. is it best to have a script with all our team user logins in a script? How would the project recognise a team member which will create a login for them so once the project is deployed they can login to their local db? &lt;/font&gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Using a 1-touch/click action (preferably outside of VS2010) to get latest, build project &amp;amp; deploy to local sandbox &lt;/font&gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Same as above but to a system test server&lt;/font&gt;&lt;/em&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;JT: There are quite a few questions there. Firstly I’ll say that its great to hear of sandboxed environments and Continuous Integration (CI) being used – I openly advocate these techniques in my blog post &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/01/01/implementing-sql-server-solutions-using-visual-studio-2010-database-projects-a-compendium-of-project-experiences.aspx"&gt;Implementing SQL Server solutions using Visual Studio 2010 Database Projects – a compendium of project experiences&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Now, taking each question in turn:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Windows Auth for local deploys. I’m not sure if there’s any recognised best practise here but if developers are working on local sandboxes I would assume they would have sysadmin rights so I’m not sure there’s a need to have a script of team logins. Perhaps I have misunderstood the question in which case please clarify in the comments below. I will say this though – I think its better to have a Windows group that you can move all of your devs in and out of rather than having to modify a script each time a user joins your team. &lt;/li&gt;    &lt;li&gt;1-click get latest, build &amp;amp; deploy. Scripting your build &amp;amp; deploy is something else I advocate in the &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/01/01/implementing-sql-server-solutions-using-visual-studio-2010-database-projects-a-compendium-of-project-experiences.aspx"&gt;aforementioned blog post&lt;/a&gt;:       &lt;blockquote&gt;       &lt;p&gt;&lt;em&gt;Building and deploying your datadude projects within Visual Studio can become a real time hog; in my experience its not unusual for deployments to take many minutes and your Visual Studio environment will be unavailable for further development work during that time. For that reason I recommend investing some time in writing some msbuild scripts that will build and deploy your project(s) from the command-line.&lt;/em&gt;&lt;/p&gt;     &lt;/blockquote&gt;      &lt;p&gt;I’ll go further here and say that the script with which you use to build and deploy to your sandbox should be the same script as which you use for your production environment and everything in between. The script should take a parameter value to name the environment and then deploy appropriately.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;See 2. &lt;/li&gt; &lt;/ol&gt;    &lt;hr /&gt;Hope that is useful. Any questions? Please put them in the comments.    &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>“Add as object” or “Add as script”? [SSDT]</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2013/01/04/add-as-object-or-add-as-script-ssdt.aspx</link><pubDate>Fri, 04 Jan 2013 14:15:46 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47006</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;In SQL Server Data Tools (SSDT) one way to create a new object is to right click on a folder in Solution Explorer and point to Add. Doing so will display this menu:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_20905F62.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0215F8AC.png" width="505" height="203" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;A number of options are offered for creating a brand new object (“function”, “table”, “stored proc” etc…) and one of them is “Script”. If your preference is to handcraft the DDL for every database object without resorting to a GUI then you may choose to use the “Script” option because, after all, every file is just a DDL script – why not write the thing from scratch? There is however one fundamental difference between the Script” option and all the other options that you should be aware of.&lt;/p&gt;  &lt;p&gt;For the screenshot below I added a script and handcrafted a simple CREATE TABLE statement:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML760417d0_6BDFDD59.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SNAGHTML760417d0" border="0" alt="SNAGHTML760417d0" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML760417d0_thumb_6D44002B.png" width="778" height="359" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Notice that the table is defined in the dbo schema but it is not appearing in SQL Server Object Explorer under the dbo schema node. Why is that? The answer is actually pretty simple. If I select Script1.sql in Solution Explorer and hit F4 the properties window appears and we see this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_3686A527.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7C97623A.png" width="304" height="276" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The Build Action property of the file is set to “None” which means that the file does not get included in a build and hence any objects defined within that file will not appear in our database. This is the default behaviour when you Add as script whereas the default behaviour when you explicitly add an object is to set Build Action=Build. That is the fundamental difference between adding a script and adding a specific object.&lt;/p&gt;  &lt;p&gt;This is one of those nuances of SSDT that is an easy problem to spot when you know about it but can cause you to spend hours hunting around for a solution if you do not (believe me, I’ve been there). Be aware of it!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>SQL Server Data Tools does support required variables</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2012/02/12/sql-server-data-tools-does-support-required-variables.aspx</link><pubDate>Sun, 12 Feb 2012 11:58:24 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:41704</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;Over the past few years of using datadude (aka DBPro aka Visual Studio Database Projects) I have fallen prey to a peculiar little nuance – if you forget to supply a value for a sqlcmd variable then it will simply use a default and often that is not the desired behaviour. Hence why yesterday I submitted the following suggestion to &lt;a href="http://connect.microsoft.com/sqlserver/feedback"&gt;http://connect.microsoft.com/sqlserver/feedback&lt;/a&gt; :&lt;/p&gt;  &lt;blockquote&gt;   &lt;h3&gt;&lt;em&gt;Specify sqlcmdvars properties as &amp;quot;required to be overridden”&lt;/em&gt;&lt;/h3&gt;    &lt;p&gt;&lt;em&gt;In my current place of work I am responsible for maintaining our datadude projects and we have another team that is in charge of deployments. Hence, when we place new properties into the sqlcmdvars file I need to tell the deployment team what values to supply for that property per environment (dev, systest, uat, prod).       &lt;br /&gt;Unfortunately lack of communication/human error occasionally creeps in and, for whatever reason, no value gets supplied for some property at deployment time. If this is the case the default value as specified in the sqlcmdvars file gets used instead - invariably this will be the wrong value. I would like a mechanism within SSDT of preventing this from ever happening.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;One simple way to prevent this would be to specify that a sqlcmdvars property is *required* to be overridden during the deployment. In other words, never use the default. if an override is not supplied at deployment time then the deployment should fail.       &lt;br /&gt;Note that this stipulation should only be in place when deployment occurs from the command-line - if deploying from Visual Studio the default should be allowed (simply because Visual Studio doesn't provide a way to specify anything other than the default value supplied in the sqlcmdvars file).&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="https://connect.microsoft.com/sqlserver/feedback/details/724366/ssdt-specify-sqlcmdvars-properties-as-required-to-be-overridden#details"&gt;&lt;em&gt;https://connect.microsoft.com/sqlserver/feedback/details/724366/ssdt-specify-sqlcmdvars-properties-as-required-to-be-overridden#details&lt;/em&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;It transpires that this requested feature is already available in the forthcoming SQL Server Data Tools (SSDT) as I shall now demonstrate. This screenshot shows the project properties of a SSDT project where we define the sqlcmd variables, I have defined a variable called $(Id_value):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_49257C87.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_63856F9E.png" width="732" height="259" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In SSDT the nomenclature for deploying a project is “Publish”, a function that can be found by right-clicking on a project in Solution Explorer:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_1438774A.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_05219870.png" width="368" height="248" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Selecting that brings up the Publish dialog.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_4AC6228E.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_6FE36CFA.png" width="554" height="536" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Notice how the “Publish” button is greyed out – that it because I have not supplied a value for $(Id_value); supplying a value enables the Publish button and I can go ahead and publish my project. In other words, SSDT &lt;em&gt;insists&lt;/em&gt; that I supply a value for that variable – exactly as I requested in my Connect submission.&lt;/p&gt;  &lt;p&gt;The same is true if I use the command-line publishing tool sqlpackage.exe. The following command does essentially the same thing as the above depicted Publish dialog:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt;sqlpackage.exe /TargetDatabaseName:MyDB /TargetServerName:&amp;quot;.\RC0&amp;quot; /Action:Publish /SourceFile:&amp;quot;TestRequiredSqlCmdVars.dacpac&amp;quot;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Executing that gives me an error:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Publishing to database 'MyDB' on server '.\RC0'.     &lt;br /&gt;&lt;font color="#ff0000"&gt;*** Missing values for the following SqlCmd variables:       &lt;br /&gt;'Id_value'.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here’s a screenshot showing the same:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_40454E6E.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_05E9D88D.png" width="618" height="201" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In order to supply a value for the variable from the command-line you need to use the /v: switch like so:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;gt;sqlpackage.exe /TargetDatabaseName:MyDB /TargetServerName:&amp;quot;.\RC0&amp;quot; /Action:Publish /SourceFile:&amp;quot;TestRequiredSqlCmdVars.dacpac&amp;quot; &lt;strong&gt;/v:Id_value=1&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_4B8E62AB.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5C265D99.png" width="617" height="201" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As you can see, publish was successful!&lt;/p&gt;  &lt;p&gt;So there you go, using SSDT you’ll no longer be able to fall prey to the problem I highlighted at the top of this blog post. In a later blog post I’ll show how you CAN supply a default value if you want to and also how you can override for your local environment.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;@jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Thoughts on Test Driven Database Development</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2012/01/26/thoughts-on-test-driven-database-development.aspx</link><pubDate>Thu, 26 Jan 2012 08:30:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:41327</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank"&gt;Test-Driven Development (TDD)&lt;/a&gt; is a software development practise that has been around for a few years. Wikipedia describes it as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;i&gt;Test-driven development (TDD) is a &lt;a href="http://en.wikipedia.org/wiki/Software_development_process" title="Software development process"&gt;software development process&lt;/a&gt; that relies on the repetition of a very short development cycle: first the developer writes a failing automated &lt;a href="http://en.wikipedia.org/wiki/Test_case" title="Test case"&gt;test case&lt;/a&gt; that defines a desired improvement or new function, then produces code to pass that test and finally &lt;a href="http://en.wikipedia.org/wiki/Code_refactoring" title="Code refactoring"&gt;refactors&lt;/a&gt; the new code to acceptable standards. &lt;a href="http://en.wikipedia.org/wiki/Kent_Beck" title="Kent Beck"&gt;Kent Beck&lt;/a&gt;,
 who is credited with having developed or 'rediscovered' the technique, 
stated in 2003 that TDD encourages simple designs and inspires 
confidence.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;&lt;a href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank"&gt;http://en.wikipedia.org/wiki/Test-driven_development&lt;/a&gt;&lt;/i&gt;&lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since 2003 TDD practises have seen refinements such as &lt;a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development" target="_blank"&gt;Behavior-Driven Development&lt;/a&gt; and &lt;a href="http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd" target="_blank"&gt;Uncle Bob's Three Rules of TDD&lt;/a&gt;, all the while TDD has pretty much become an accepted way of developing quality software. Accepted that is everywhere outside of the database development arena and that is the arena in which I spend my working life. TDD simply has not, in my opinion, caught on with database developers like it has our appdev brethren and I was reminded of this yesterday when &lt;a href="https://twitter.com/#%21/atulthakor" target="_blank"&gt;Atul Thakor&lt;/a&gt; asked on Twitter:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;i&gt;anyone done TDD for database development and would they recommend it?&lt;/i&gt; &lt;i&gt;&lt;br&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;&lt;a href="https://twitter.com/#%21/atulthakor/status/161886007929733120" target="_blank"&gt;https://twitter.com/#!/atulthakor/status/161886007929733120&lt;/a&gt;&lt;/i&gt;&lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To which my answer was an emphatic:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;i&gt;(1) yes &amp;amp; (2) absolutely, yes&lt;/i&gt;&lt;/p&gt;
&lt;i&gt;&lt;a href="https://twitter.com/#%21/jamiet/status/161894215217987585" target="_blank"&gt;https://twitter.com/#!/jamiet/status/161894215217987585&lt;/a&gt;&lt;/i&gt;&lt;/blockquote&gt;

&lt;p&gt;I'll use this blog post to expand on that outside of 140 characters.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;In October 2010 I undertook a mini-project for the client I was working for at the time (a bank) where a colleague and I were tasked with building the database portion of a system that would support reconciliation of our ETL processes. It was a nice piece of work in that it was small, well-scoped, time-bound, greenfield, did not have any external dependancies and had a technically savvy product owner. We sat down at the start and decided that this was an ideal opportunity to trial TDD as a method of developing a database; I would write the failing tests and my colleague would make the tests pass. We came up with some guiding principles and, although we didn't know it at the time, they were pretty close to Uncle Bob's three rules.&lt;/p&gt;

&lt;p&gt;I used Visual Studio 2010's &lt;a href="http://msdn.microsoft.com/en-us/library/bb381703%28v=vs.80%29.aspx" target="_blank"&gt;database unit testing framework&lt;/a&gt;&lt;sup&gt;1&lt;/sup&gt; to write my tests and have them run as part of our Continuous Integration (CI) build (see &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/08/20/setting-up-database-unit-testing-as-part-of-a-continuous-integration-build-process-vs2010-db-tools-datadude.aspx" target="_blank"&gt;Setting up database unit testing as part of a Continuous Integration build process&lt;/a&gt;). I would write the tests, check-in, the CI build would fail and my colleague would "get latest" in order to see what code he had to write to stop the build from failing. To cut a long story short the use of TDD was considered to be a great success; we shipped a working system on time/on budget and moreover, &lt;i&gt;&lt;b&gt;even though I didn't write a scrap of code that went into production I have never had more confidence that a system I was involved in building worked as intended&lt;/b&gt;&lt;/i&gt;. That's quite a statement. My confidence stemmed from the fact that as the test author I was ultimately responsible for ensuring that the system did what it was supposed to; I could qualify my confidence by pointing at our CI build and highlighting the number of tests that were passing and how that number had steadily increased as the project progressed.&lt;/p&gt;&lt;p&gt;By the time the project had finished the database consisted of (if memory serves me correctly) 6 tables and about 10 stored procedures or functions (so yes, very small). To test that we had roughly 70 tests that were getting run up to 20 times a day. The project had taken about two months from start-up to final delivery - you can make your own opinions as to whether you consider that prompt or tardy but our product owner was happy and that's pretty much all that counted as far as I was concerned.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Since that project I have moved onto other clients and at each one I have always extolled the use of database unit testing; we haven't always practised TDD but at each one we &lt;i&gt;have &lt;/i&gt;been writing database unit tests and in the future I suspect that a client's willingness (or lack thereof) to use database unit testing will be a major factor in influencing whether we end up working together or not.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Are you a database developer doing database unit testing or perhaps even TDD? Let me know in the comments, I'd love to hear about others' experiences.&lt;/p&gt;&lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;@jamiet&lt;/a&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;Yes, that linked-to article from &lt;u&gt;7 years ago&lt;/u&gt; is the best one I 
could find to describe what Visual Studio's Database Unit testing Framework actually is - sort it out Microsoft!&lt;/p&gt;&lt;p&gt;UPDATE: I have just remembered that Jamie Laflen has written an excellent whitepaper entitled &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc164243.aspx" target="_blank"&gt;Apply Test-Driven Development to your Database Projects&lt;/a&gt; that goes into much more detail about how to achieve database TDD using Visual Studio than I have here. Well worth a read. &lt;/p&gt;</description></item><item><title>Implementing SQL Server solutions using Visual Studio 2010 Database Projects – a compendium of project experiences</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2012/01/01/implementing-sql-server-solutions-using-visual-studio-2010-database-projects-a-compendium-of-project-experiences.aspx</link><pubDate>Sun, 01 Jan 2012 18:13:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:40711</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;Over the past eighteen months I have worked on four separate projects for customers that wanted to make use of Visual Studio 2010 Database projects to manage their database schema.* All the while I have been trying to take lots of notes in order that I can write the blog post that you are reading right now – a compendium of experiences and tips from those eighteen months. I should note that this blog post should not necessarily be taken as a recommendation to actually &lt;i&gt;use&lt;/i&gt; database projects in Visual Studio 2010 – it is intended to be useful for those of you that have already made the decision to use them; having said that, I do make recommendations as to actions I think you should take if you have made that decision.&lt;/p&gt;  &lt;p&gt;First let’s be clear what we’re talking about here. Visual Studio Database Projects have been known by a few different names down the years, some of which you may be familiar with. If you have ever heard the terms datadude, DBPro, teamdata, TSData or Visual Studio Team System for Database Professionals then just know that all of these terms refer to the same thing, namely the project type highlighted below when starting a new project in Visual Studio:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_4302F9CA.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4079C80C.png" width="748" height="411"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;From here onwards I am going to refer to Visual Studio Database projects and all the features therein simply as datadude because that’s a popular colloquial name (and is also much quicker to type). Know also that at the time of writing the features that I am talking about here are currently undergoing some changes ahead of the next release of SQL Server (i.e. SQL Server 2012) in which these features are mooted to be delivered under a new moniker - SQL Server Developer Tools (SSDT).&lt;/p&gt;  &lt;p&gt;OK, with all those preliminaries out of the way let’s dig in.&lt;/p&gt;  &lt;h1&gt;Continuous Integration&lt;/h1&gt;  &lt;p&gt;&lt;a href="http://www.martinfowler.com/articles/continuousIntegration.html" target="_blank"&gt;Continuous Integration&lt;/a&gt; (CI) is a development practise that has existed for many years but in my experience has not been wholly embraced by the database community. The idea behind CI for databases is that every time a developer checks-in a piece of code be it a stored procedure, a table definition or whatever, the entire database project is built and then deployed to a database instance. Microsoft provide a useful article &lt;a href="http://msdn.microsoft.com/en-us/library/aa833165.aspx" target="_blank"&gt;An Overview of Database Build and Deployment&lt;/a&gt; that goes some way to explaining how to setup your CI deployment.&lt;/p&gt;  &lt;p&gt;CI is one of the fundamental tenets that underpins a lot of the things I talk about later in this blog post and hence gives rise to my first recommendation when using datadude:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #1: Use Source Control and implement a Continuous Integration deployment&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;i&gt;In an earlier draft of this blog post I outlined in detail the CI configuration from one of the aforementioned projects. Its not suitable for inclusion at this point in the current draft but I still think there is some useful information to be gleaned so I have included it below in “Appendix – An example CI configuration”.&lt;/i&gt;&lt;/p&gt;  &lt;h1&gt;Composite Projects&lt;/h1&gt;  &lt;p&gt;Each of the four aforementioned projects were brownfield projects meaning that each already encompassed some established, deployed, databases and they wanted to bring those databases under the control of datadude. Each project had thousands of objects across multiple databases and in this situation it is very likely that some of the stored procedures, views or functions will refer to objects in one of the other databases. The way to resolve those references is to use &lt;a href="http://blogs.msdn.com/b/gertd/archive/2007/07/26/database-references.aspx" target="_blank"&gt;database references&lt;/a&gt; however once you have applied all of your database references it is still very possible that you will run into a situation where code in database A refers to an object in database B while at the same time database B refers to an object in database A. This is depicted in the following figure:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_05B21F36.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_2BA7CF8C.png" width="435" height="228"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here we have a view [DB1]..[View2] that selects data from [DB2]..[Table1] and a view [DB2]..[View1] that selects data from [DB1]..[Table1]. Datadude does not allow a database reference from [DB2] to [DB1] if there is already a database reference from [DB2] to [DB1] and hence will return an error akin to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;SQL03006: View: [dbo].[View1] has an unresolved reference to object [DB1].[dbo].[Table1]. &lt;/li&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0395206D.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_096FC406.png" width="574" height="108"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;We have the proverbial chicken-and-egg problem, [DB1] can’t be created before [DB2] and vice versa. This problem is solved by using &lt;i&gt;&lt;b&gt;Composite Projects&lt;/b&gt;&lt;/i&gt; (not to be confused with Partial Projects) which allow you to split objects that are intended to be in the same database over multiple datadude projects. I could go over how you set one of these things up but there’s really no need because there is a rather excellent walkthrough on MSDN at &lt;a href="http://msdn.microsoft.com/en-us/library/dd193415.aspx" target="_blank"&gt;Walkthrough: Partition a Database Project by Using Composite Projects&lt;/a&gt;; the reason for me mentioning it here is to make you aware that composite projects exist and of the problem that they solve. If you are introducing datadude into a brownfield project then it is highly likely that you are going to require composite projects so learn them and learn them good.&lt;/p&gt;  &lt;p&gt;One important last note about composite projects is to answer the question “How does the tool know that the multiple projects refer to the same database?” The answer is given at the walkthrough that I linked to above; namely, it says:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_5A3DD86E.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="Composite projects - referring to the same database" border="0" alt="Do not specify server variables and values or database variables and values when you define references in a composite project. Because no variables are defined, the referenced project is assumed to share the target server and database of the current project." src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7509FE7A.png" width="631" height="116"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;“Do not specify server variables and values or database variables and values when you define references in a composite project. Because no variables are defined, the referenced project is assumed to share the target server and database of the current project.”&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So now you know! To put it another way, if you reference one project from another and don’t tell datadude that the two projects refer to different databases then it assumes they refer to the &lt;i&gt;same &lt;/i&gt;database.&lt;/p&gt;  &lt;h1&gt;Code Analysis&lt;/h1&gt;  &lt;p&gt;Datadude provides the ability to analyse your code projects for code in stored procedures and functions that it considers to be inferior and highlight it – this feature is called &lt;b&gt;&lt;i&gt;Code Analysis&lt;/i&gt;&lt;/b&gt;. Note that Code Analysis will not highlight code that is syntactically incorrect (datadude does that already, which may well be considered its core feature), it highlights code that is syntactically correct but may be considered defective when executed. Specifically Code Analysis will highlight the following perceived code defects (click through on the links for explanations of why these are considered code defects):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193296.aspx" target="_blank"&gt;Use of SELECT *&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd172121.aspx" target="_blank"&gt;Use of @@IDENTITY rather than SCOPE_IDENTITY()&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193263.aspx" target="_blank"&gt;NCHAR &amp;amp; NVARCHAR fields whose maximum length is 1 or 2&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd172122.aspx" target="_blank"&gt;Deprecated join syntax&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd172136.aspx" target="_blank"&gt;An output parameter that might not be assigned to&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193269.aspx" target="_blank"&gt;Casts that could result in data loss&lt;/a&gt; (in my experience this is the one that shows up most often – particularly in inherited code) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd172134.aspx" target="_blank"&gt;Use of special characters in object names&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193421.aspx" target="_blank"&gt;Use of reserved words&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd172115.aspx" target="_blank"&gt;Use of sp_ prefix for stored procedures&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193249.aspx" target="_blank"&gt;Use of unindexed columns in IN predicates&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193273.aspx" target="_blank"&gt;Use of patterns beginning with a wildcard in a LIKE predicate&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193264.aspx" target="_blank"&gt;Code that would not use an existing index that might actually be beneficial&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193267.aspx" target="_blank"&gt;Use of ISNULL() on nullable columns&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193285.aspx" target="_blank"&gt;Deterministic function calls in a WHERE predicate&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In my opinion the best aspect of Code Analysis is that it can be run as part of your Continuous Integration deployment meaning that if anyone checks in some deficient code, BOOM, your CI deployment fails and the developer is left red-faced. Nothing else has increased the code quality on my projects quite like running Code Analysis as part of a CI deployment.&lt;/p&gt;  &lt;p&gt;Hopefully I have convinced you that turning on Code Analysis is a good idea. If you agree then head to the project properties and check the box labelled &lt;b&gt;Enable Code Analysis on Build&lt;/b&gt;. I also recommend checking the &lt;b&gt;Treat warnings as errors&lt;/b&gt; boxes otherwise you’ll find that &lt;a href="http://www.codinghorror.com/blog/2007/08/discipline-makes-strong-developers.html" target="_blank"&gt;undisciplined developers&lt;/a&gt; will simply ignore the warnings.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0CC135E1.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="Enable datadude code analysis" border="0" alt="Enable datadude code analysis" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_129BD97A.png" width="583" height="204"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;N.B. Incidentally if you have time I highly recommend that you go and read the blog post I linked to there – &lt;/i&gt;&lt;a href="http://www.codinghorror.com/blog/2007/08/discipline-makes-strong-developers.html" target="_blank"&gt;&lt;i&gt;Discipline Makes Strong Developers&lt;/i&gt;&lt;/a&gt;&lt;i&gt; by Jeff Atwood. I’ve read many thousands of blog posts in my time and that is the one that has influenced me more than any other.&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Turning on Code Analysis on a greenfield project is a no-brainer. On a brownfield project its not quite so easy – on a recent engagement I moved a single database into datadude and turned on Code Analysis which immediately found over two thousand perceived code defects. I generally abhor the use of that famous maxim &lt;a href="http://en.wikipedia.org/wiki/If_it_ain%27t_broke,_don%27t_fix_it#.22If_it_ain.27t_broke.2C_don.27t_fix_it..22" target="_blank"&gt;if it aint broke, don’t fix it&lt;/a&gt;&lt;i&gt;&lt;/i&gt; in our industry but on occasions like this you may be well advised to heed that advice and leave well alone for fear of breaking code that does what it is supposed to (no matter how inefficiently it does it). Instead you do have the option to suppress Code Analysis warnings/errors:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_434EE125.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="Suppress datadude code analysis" border="0" alt="Suppress datadude code analysis" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_492984BE.png" width="585" height="195"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I advise using Code Analysis suppression sparingly. Recently I discovered that one of the developers on my team had decided it was OK to simply suppress every error that was thrown by Code Analysis without first investigating the cause. I was not amused!&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #2: Turn on Code Analysis&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h1&gt;Realising the value of idempotency&lt;/h1&gt;  &lt;p&gt;An operation is considered idempotent if it produces the same result no matter how many times that operation is applied; for example, multiplication by a factor of one is an idempotent operation – no matter how many times you multiple a number by one the result will always be the same.&lt;/p&gt;  &lt;p&gt;Idempotency is a vital facet of database deployment using datadude. Datadude tries to ensure that no matter how many times you deploy the same project the state of your database should be the same after each deployment. The implication here is that during a deployment datadude will examine the target database to see what changes (if any) need to be made rather than simply attempting to create lots of objects; if all the objects already exist nothing will be done. In my opinion this is the single biggest benefit of using datadude – you don’t have to determine what needs to be done to change your database schema to the desired state, datadude does it for you.&lt;/p&gt;  &lt;p&gt;If I have convinced you about the value of idempotency within datadude then you should also realise that the same rigour should be applied to data as well. Datadude provides Post-Deployment scripts that allow you to deploy data to your schema however there is no inbuilt magic here – datadude will simply go and run those scripts as-is, it will not try and comprehend the contents of those scripts. What this means is that you, the developer, are responsible for making your Post-Deployment scripts idempotent and the easiest way to do that is to employ the T-SQL MERGE statement.&lt;/p&gt;  &lt;p&gt;T-SQL’s INSERT is not sufficient as it will work once and thereafter fail as it will be attempting to insert already inserted data; this gives rise to my third recommendation:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #3: When running your deployment in a test environment, run it more than once.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h1&gt;No-brainer Recommendations&lt;/h1&gt;  &lt;p&gt;I consider Code Analysis and Idempotency to be so important that I called them out as dedicated headlines. In this section I’ll outline some additional simple measures that you can undertake and which will, if employed correctly, have a profound effect on the success of your datadude projects.&lt;/p&gt;  &lt;h2&gt;Putting a build number into the DB&lt;/h2&gt;  &lt;p&gt;I find it is very useful to maintain a log of deployments that have been made to a database and my chosen method is to use a Post-Deployment script to insert a value into some table. Here’s the definition of the table I use for this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;CREATE TABLE &lt;/span&gt;&lt;span style="color:black;"&gt;[dbo].[DeployLog]          &lt;br&gt;&lt;/span&gt;&lt;span style="color:gray;"&gt;(          &lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:black;"&gt;[BuildId]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;50&lt;/span&gt;&lt;span style="color:gray;"&gt;)          &lt;br&gt;,&amp;nbsp; &lt;/span&gt;&lt;span style="color:black;"&gt;[DeployDatetime]&amp;nbsp;&amp;nbsp;&amp;nbsp; SMALLDATETIME          &lt;br&gt;&lt;/span&gt;&lt;span style="color:gray;"&gt;,&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;CONSTRAINT&amp;nbsp; &lt;/span&gt;&lt;span style="color:black;"&gt;PK_dboDeployLog &lt;/span&gt;&lt;span style="color:blue;"&gt;PRIMARY KEY &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;[DeployDatetime]&lt;/span&gt;&lt;span style="color:gray;"&gt;)          &lt;br&gt;)&lt;/span&gt;&lt;/code&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In my Post-Deployment script I will use:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;INSERT &lt;/span&gt;&lt;span style="color:black;"&gt;[dbo].[DeployLog]&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;[BuildId]&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:black;"&gt;[DeployDatetime]&lt;/span&gt;&lt;span style="color:gray;"&gt;)          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:red;"&gt;'$(BuildId)'&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;());&lt;/span&gt;&lt;/code&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;to insert a row into that table during every deployment. &lt;font color="#ff0000"&gt;$(BuildId)&lt;/font&gt; is a variable defined in the .sqlcmdvars file of my project:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0ECE0EDD.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0D8975FE.png" width="293" height="216"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here is what we see inside that file:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_5E578A66.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_64322DFF.png" width="526" height="219"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The &lt;font color="#ff0000"&gt;$(BuildId)&lt;/font&gt; variable has been defined with a default value of UNKNOWN and hence subsequent deployments from Visual Studio will result in the following:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_5BCE58A8.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0F964EFA.png" width="513" height="284"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;On first glance that might not seem particularly useful however it comes into its own if you are doing CI deployments (see recommendation #1) because each build in a CI environment will result in a new build identifier. The following command-line call to vsdbcmd.exe is how deployments are generally done using datadude, note the presence of the &lt;b&gt;/p:BuildId&lt;/b&gt; switch:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;..\Tools\VSDBCMD\vsdbcmd.exe /Action:Deploy /ConnectionString:"Data Source=.;Integrated Security=True;Pooling=False" &lt;b&gt;/p:BuildId="some-value"&lt;/b&gt; /DeployToDatabase:+ /ManifestFile:.\FinanceDB\sql\release\FinanceDB.deploymanifest&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Your CI tool should be able to replace “some-value” with an identifier for the current build (that’s outside the scope of this blog post but any CI tool worth its salt will be able to do this) – when the deployment executes that value will then make its way into your [dbo].[DeployLog] table and you will have a self-maintaining history of all the deployments (datetime &amp;amp; build identifier) that have been made to your database.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #4: Maintain an automated history of your deployments&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Use Schema View&lt;/h2&gt;  &lt;p&gt;It is natural to navigate through all of the objects in your database project using Solution Explorer however datadude provides a better mechanism for doing just that – the Schema View window.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_6E36A95D.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_781B9AC8.png" width="250" height="304"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Schema View provides a logical view of all the objects defined in your database project regardless of which file they may be defined in. That is very useful for many reasons, not least because it makes it easy to locate whichever object you are after – that’s advantageous if multiple objects are defined in the same file. Moreover if some files have property BuildAction=”Not In Build” (see later) they won’t show up in Schema View (this is a good thing by the way). Schema View is also the place that operations such as refactoring and dependency analysis are launched from.&lt;/p&gt;  &lt;p&gt;Some people think that it is important that the name of each file in a datadude project should accurately reflect the object defined within. I disagree; object renames mean that maintaining the filenames becomes laborious and having the Schema View means you never have to use the filenames to navigate your project anyway.&lt;/p&gt;  &lt;p&gt;One final reason to use Schema View is the External Elements button:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_04A947E5.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_6349A248.png" width="356" height="152"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Toggling this button on means that objects in referenced projects show up in the project that they are referenced from (this is particularly useful if you are using Composite Projects). Note in the following screenshot how the object [dbo].[t1] in project Database2 appears in the [dbo] schema of Database3 – that’s because Database3 has a reference to Database2.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_62050969.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_47586D50.png" width="243" height="439"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;For those reasons my fifth recommendation is:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #5: Use Schema View in preference to Solution Explorer&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You will still need Solution Explorer to navigate files that do not contain database objects (e.g. Post-Deployment scripts) but ordinarily you should spend most of your time interacting with Schema View.&lt;/p&gt;  &lt;h2&gt;Make liberal use of PRINT statements in Pre/Post-Deployment Scripts&lt;/h2&gt;  &lt;p&gt;When you deploy a datadude project datadude will take care of telling you what it is up to. For example, the following screenshot shows the output from deploying the already discussed [dbo].[DeplogLog]:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_11074541.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_68F49621.png" width="479" height="117"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Of course it only does this for objects that it knows about and that doesn’t include anything in your Pre or Post \deployment scripts so you need to take responsibility for outputting pertinent information from those scripts. Here I have amended the script that inserts into [dbo].[DeployLog]:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;SET NOCOUNT ON&lt;/span&gt;&lt;span style="color:gray;"&gt;;          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;INSERT &lt;/span&gt;&lt;span style="color:black;"&gt;[dbo].[DeployLog]&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;[BuildId]&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:black;"&gt;[DeployDatetime]&lt;/span&gt;&lt;span style="color:gray;"&gt;)          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:red;"&gt;'$(BuildId)'&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;());          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span&gt;@@ROWCOUNT &lt;/span&gt;&lt;span style="color:blue;"&gt;as NVARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;5&lt;/span&gt;&lt;span style="color:gray;"&gt;)) + &lt;/span&gt;&lt;span style="color:red;"&gt;N'rows inserted into [dbo].[DeployLog], BuildId=$(BuildId)'&lt;/span&gt;&lt;span style="color:gray;"&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This gives us much more useful output:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_159D4FFB.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_46BC8A9B.png" width="475" height="122"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Adding PRINT statements to your Pre &amp;amp; Post Deployment scripts is so easy it really is a no-brainer and hence my next recommendation is:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #6: Any action in a Pre or Post-Deployment Script should use PRINT to state what has been done&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Output variable values in your Pre-Deployment script&lt;/h2&gt;  &lt;p&gt;This is in the same vein as the previous bullet-point – output as much information as is possible. In this case we’re talking about outputting the values of all variables that are stored in the .sqlcmdvars file; first, a reminder of what’s in that file:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_73654474.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5924DB50.png" width="526" height="219"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here is the contents of my amended Pre-Deployment Script:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:red;"&gt;'DefaultDataPath=$(DefaultDataPath)'&lt;/span&gt;&lt;span style="color:gray;"&gt;;          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:red;"&gt;'DatabaseName=$(DatabaseName)'&lt;/span&gt;&lt;span style="color:gray;"&gt;;          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:red;"&gt;'DefaultLogPath=$(DefaultLogPath)'&lt;/span&gt;&lt;span style="color:gray;"&gt;;          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:red;"&gt;'BuildId=$(BuildId)'&lt;/span&gt;&lt;span style="color:gray;"&gt;;&lt;/span&gt;&lt;/code&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;And the resultant output:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_22D3B341.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_3D9FD94D.png" width="568" height="119"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This is the sort of simple amendment that will pay off in spades later in your project (especially if you are supplying many values from the command-line) and again, its so easy to do it there really is no reason not to. Just remember to update your Pre-Deployment script whenever you add new variables to .sqlcmdvars.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #7: Output the value of all variables in your Pre-Deployment script&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;One Object Per File&lt;/h2&gt;  &lt;p&gt;Datadude doesn’t restrict what can go in a file, for example the following file, “t.table.sql”, defines three objects; a table, a primary key and a view:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_75721D70.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_1B67CDC7.png" width="352" height="248"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Even though they’re all defined in the same file they show up in Schema View separately (one of the aforementioned benefits of using Schema View):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_6C35E22F.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_3D03F698.png" width="314" height="355"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;That said, just because you can doesn’t mean that you should. I prefer to go for one object per file for the simple reason that its easier to track the history of an object via Source Control. Moreover, if an object is no longer required then it is a simple change to just remove the file containing that object from the build (see “Don’t delete anything from your project” later) as opposed to editing a file to remove all traces of an object.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #8: Each database object should be defined in a dedicated file&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Time your Pre and Post Deployment Scripts&lt;/h2&gt;  &lt;p&gt;Its always useful to know where time is spent when doing deployments, in my experience the majority of time spent is in the Post-Deployment script (your mileage may vary of course). An easy win is to output the time taken to run your Pre and Post Deployment scripts. Adapt your Pre-Deployment script so that it looks something like this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;DECLARE &lt;/span&gt;&lt;span&gt;@vPreDeploymentStartTime &lt;/span&gt;&lt;span style="color:blue;"&gt;DATETIME = &lt;/span&gt;&lt;span style="color:magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;();          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:red;"&gt;'****************Begin Pre-Deployment script at ' &lt;/span&gt;&lt;span style="color:gray;"&gt;+&lt;/span&gt;&lt;span style="color:magenta;"&gt;CONVERT&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;30&lt;/span&gt;&lt;span style="color:gray;"&gt;),&lt;/span&gt;&lt;span style="color:magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;(),&lt;/span&gt;&lt;span style="color:black;"&gt;120&lt;/span&gt;&lt;span style="color:gray;"&gt;) + &lt;/span&gt;&lt;span style="color:red;"&gt;'***********************'&lt;/span&gt;&lt;span style="color:gray;"&gt;;          &lt;br&gt;&lt;/span&gt;&lt;span style="color:gray;"&gt;         &lt;br&gt;&lt;/span&gt;&lt;span style="color:green;"&gt;/*Call other scripts from here using SQLCMD's :r syntax          &lt;br&gt;Example:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :r .\myfile.sql&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;*/           &lt;br&gt;          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:red;"&gt;'Pre-Deployment duration = ' &lt;/span&gt;&lt;span style="color:gray;"&gt;+ &lt;/span&gt;&lt;span style="color:magenta;"&gt;CONVERT&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;5&lt;/span&gt;&lt;span style="color:gray;"&gt;),&lt;/span&gt;&lt;span style="color:magenta;"&gt;DATEDIFF&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;ss&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span&gt;@vPreDeploymentStartTime&lt;/span&gt;&lt;span style="color:gray;"&gt;,&lt;/span&gt;&lt;span style="color:magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;())) + &lt;/span&gt;&lt;span style="color:red;"&gt;' seconds'&lt;/span&gt;&lt;span style="color:gray;"&gt;;          &lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;PRINT &lt;/span&gt;&lt;span style="color:red;"&gt;'****************End Pre-Deployment script at ' &lt;/span&gt;&lt;span style="color:gray;"&gt;+&lt;/span&gt;&lt;span style="color:magenta;"&gt;CONVERT&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;/span&gt;&lt;span style="color:black;"&gt;30&lt;/span&gt;&lt;span style="color:gray;"&gt;),&lt;/span&gt;&lt;span style="color:magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color:gray;"&gt;(),&lt;/span&gt;&lt;span style="color:black;"&gt;120&lt;/span&gt;&lt;span style="color:gray;"&gt;) + &lt;/span&gt;&lt;span style="color:red;"&gt;'***********************'&lt;/span&gt;&lt;span style="color:gray;"&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;then do similar for your Post-Deployment script. When you deploy your output will include the following:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_3BBF5DB9.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_217EF495.png" width="593" height="201"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Note the lines:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************Begin Pre-Deployment script at 2011-12-31 20:00:34***********************        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Pre-Deployment duration = 0 seconds         &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************End Pre-Deployment script at 2011-12-31 20:00:34***********************         &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Consolas"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************Begin Post-Deployment script at 2011-12-31 20:00:34***********************        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Post-Deployment duration = 0 seconds         &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************End Post-Deployment script at 2011-12-31 20:00:34***********************&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In this particular case its not all that useful to know that the deployment took 0 seconds but if and when your deployments snowball to many minutes it will be useful to know how long your scripts are taking at which point you can investigate further by timing each individual step in your Pre and Post Deployment scripts.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #9: Time your deployments and output the timings&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Use sqlcmdvars and the command-line as much as possible&lt;/h2&gt;  &lt;p&gt;Hardcoding any value into a piece of code is a fraught practise; you should assume that values previously thought to be constant may not be so in the future. You can protect yourself from future changes by storing all literal values as variables in your .sqlcmdvars file. Sure, you can supply default values for those variables but you have the added advantage that they can be overridden from the command-line when deploying using &lt;a href="http://msdn.microsoft.com/en-us/library/dd193283.aspx" target="_blank"&gt;vsdbcmd.exe&lt;/a&gt;. Moreover, if you have values that are hardcoded in multiple places in your code then specifying those values in .sqlcmdvars ensures that your code adheres to the principle of &lt;a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" target="_blank"&gt;DRY&lt;/a&gt;. Lastly, if values are stored in the .sqlcmdvars file then you can output them at deploy time (see recommendation #7).&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #10: All literal values should be stored in your .sqlcmdvars file&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Every developer gets their own development database&lt;/h2&gt;  &lt;p&gt;In most SQL Server development shops that I’ve been on all developers work against a single centralised development database. To me this is an antiquated way of working because its possible that work one person is doing can conflict with that of someone else, I find it much better for every developer to work in isolation and then use the CI deployment to check that one’s code is not in conflict with anyone else’s. Datadude supports (nay encourages) this way of working with the notion of an Isolated Development Environment:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_79001280.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0CACFC15.png" width="541" height="172"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Every developer should configure their isolated development environment which, typically, would be their local instance. And so to my next recommendation:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #11: Every developer should use the Isolated Dev Environment settings in order to author their code&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Incidentally, if every developer has their own development database and you are following my earlier recommendation to use a [DeployLog] table then you can track how often a developer is bothering to deploy and test their code. On a recent project we used this evidence in a (ahem) &lt;i&gt;discussion&lt;/i&gt; with a developer who tried to convince us that he was testing his code sufficiently even though he was repeatedly causing the CI deployment to fail.&lt;/p&gt;  &lt;h2&gt;Don’t delete anything from your project&lt;/h2&gt;  &lt;p&gt;When projects are no longer required in your database then intuitively it makes sense to remove the file containing that object from the datadude project, I would however like to suggest a different approach. Rather than removing a file just change the Build property to “Not in Build”:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0B686336.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_114306CF.png" width="330" height="293"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This has the advantage that your project maintains some semblance of history of what objects have been removed from your database – that can be useful to anyone inheriting your code in the future.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #12: Use “Not in Build” to remove an object from your database&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h2&gt;Build and Deploy your datadude projects outside of Visual Studio&lt;/h2&gt;  &lt;p&gt;Building and deploying your datadude projects within Visual Studio can become a real time hog; in my experience its not unusual for deployments to take many minutes and your Visual Studio environment will be unavailable for further development work during that time. For that reason I recommend investing some time in writing some msbuild scripts that will build and deploy your project(s) from the command-line. Here are some examples that you can adapt for your own use, firstly a script to build a solution:&lt;/p&gt;  &lt;div style="font-size:10pt;"&gt;   &lt;div style="padding:2px 5px;overflow:auto;white-space:nowrap;"&gt;&lt;span&gt;&amp;lt;?&lt;/span&gt;&lt;span&gt;xml&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;version&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;1.0&lt;/span&gt;"&lt;span&gt; &lt;/span&gt;&lt;span&gt;encoding&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;utf-8&lt;/span&gt;"&lt;span&gt;?&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;lt;!--&lt;/span&gt; &lt;span&gt;Execute using:&lt;/span&gt;       &lt;br&gt;&lt;span&gt;msbuild SolutionBuild.proj&lt;/span&gt;       &lt;br&gt;&lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;Project&lt;/span&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;xmlns&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/span&gt;"       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;DefaultTargets&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Build&lt;/span&gt;"&lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;!--&lt;/span&gt; &lt;span&gt;Notes:&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When doing .net development Visual Studio Configurations are particularly useful because they can affect&lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;how the code is executed (i.e. under the Debug configuration&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; debug symbols can be used to step through the code (something like that anyway - I don't know too much about that &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;stuff).&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In DBPro, Configurations are less relevant because there is no such thing as debugging symbols. Nonetheless, they &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;can still be useful&lt;/span&gt; &lt;span&gt;for times when you want to do different things (e.g. you might want to run Code Analysis in &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;a debug situation but not in a release&lt;/span&gt;       &lt;span&gt;situation. There is a useful thread on this here: &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;"Debug vs Release" http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/a0ec0dc0-a907-45ba-a2ea-d2f0175261a7&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Note that Visual Studio Configurations should not be used to maintain different settings per environment. &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;The correct way to do that is to maintain&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seperate .sqlcmdvars files per environment and then choose which one to use at deployment time when using&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vsdbcmd.exe (use syntax "/p:SqlCommandVariablesFile=$(ProjectName)_$(Environment).sqlcmdvars")&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt; &lt;span&gt;ItemGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!--&lt;/span&gt; &lt;span&gt;List all the configurations here that you want to build&lt;/span&gt; &lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Config&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Include&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Debug&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Config&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Include&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Release&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;ItemGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Target&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Name&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Build&lt;/span&gt;"&lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Message&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Text&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Building %(Config.Identity) configuration...&lt;/span&gt;"&lt;span&gt;/&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;MSBuild&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Projects&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;.\Lloyds.UKTax.DB.sln&lt;/span&gt;"&lt;span&gt; &lt;/span&gt;&lt;span&gt;Properties&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Configuration=%(Config.Identity)&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;Target&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt; &lt;span&gt;Project&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;and secondly a script that will deploy a datadude project:&lt;/p&gt;  &lt;div style="font-size:10pt;"&gt;   &lt;div style="padding:2px 5px;overflow:auto;white-space:nowrap;"&gt;&lt;span&gt;&amp;lt;?&lt;/span&gt;&lt;span&gt;xml&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;version&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;1.0&lt;/span&gt;"&lt;span&gt; &lt;/span&gt;&lt;span&gt;encoding&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;utf-8&lt;/span&gt;"&lt;span&gt;?&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;lt;!--&lt;/span&gt; &lt;span&gt;Execute using:&lt;/span&gt;       &lt;br&gt;&lt;span&gt;msbuild SolutionDeploy.proj /Target:Deploy&lt;/span&gt;       &lt;br&gt;&lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;Project&lt;/span&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;span&gt;xmlns&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/span&gt;"      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;DefaultTargets&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Build;Deploy&lt;/span&gt;"&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt; &lt;span&gt;PropertyGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!--&lt;/span&gt; &lt;span&gt;At time of writing I don't see a reason for anything else to be used but that may change in the future hence why this &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;is a property and hence can be overriden.&lt;/span&gt; &lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Configuration&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;Debug&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span&gt;Configuration&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;DevServer&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;Data Source=GBS0039182\GLDDEV01;Integrated Security=True;Pooling=False&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span&gt;DevServer&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;PropertyGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt; &lt;span&gt;ItemGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;ProjectToBuild&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Include&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;SolutionBuild.proj&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;ItemGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;!--&lt;/span&gt; &lt;span&gt;Notes:&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add a &amp;lt;DbProj&amp;gt; item for every database project (.dbproj) that needs to be deployed. They will get deployed in the &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;order that they are listed&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thus it is your responsibility to make sure they are listed in the correct order (respecting dependency order).&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %Identity is a metadata reference. It refers to the name of the item (i.e. Include="The bit that goes here is the &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;identity")&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Note also that whatever you put for Include is important. Include="dev_thomsonj" means the project will only get &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;deployed if the&lt;/span&gt;       &lt;span&gt;deployment is being executed by username=dev_thomsonj&lt;/span&gt; &lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt; &lt;span&gt;ItemGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;DbProj&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Include&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;username&lt;/span&gt;"&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;DbName&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;MyDB&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span&gt;DbName&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;ProjectName&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;MySoln.MyDB&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span&gt;ProjectName&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;OutputPath&lt;/span&gt;&lt;span&gt;&amp;gt;\&lt;/span&gt;%(ProjectName)\sql\$(Configuration)\\cf1 &amp;lt;/&lt;span&gt;OutputPath&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;DeployConnStr&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;Data Source=localhost;Integrated Security=True;Pooling=False&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span&gt;DeployConnStr&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;DbProj&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;ItemGroup&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Target&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Name&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Build&lt;/span&gt;"&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;MSBuild&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Projects&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;@(ProjectToBuild)&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;Target&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Target&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Name&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Deploy&lt;/span&gt;"&lt;span&gt;&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!--&lt;/span&gt; &lt;span&gt;Notes:&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 09 is the hex code for TAB, hence all of the %09 references that you can see. See http://asciitable.com/ &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;for more details.&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt; &lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Message&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Text&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;USERNAME=$(USERNAME)&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Message&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Condition&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;'%(DbProj.Identity)'==$(USERNAME)&lt;/span&gt;"&lt;span&gt; &lt;/span&gt;&lt;span&gt;Text&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Deploying:&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Project%09%09%09:&amp;nbsp; %(DbProj.ProjectName)&amp;nbsp;&amp;nbsp; &lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbName%09%09%09:&amp;nbsp; %(DbProj.DbName)&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From OutputPath%09%09:&amp;nbsp; %(DbProj.OutputPath)&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To ConnStr%09%09:&amp;nbsp; %(DbProj.DeployConnStr)&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; By%09%09%09:&amp;nbsp; %(DbProj.Identity)&lt;/span&gt;"      &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Exec&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Condition&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;'%(DbProj.Identity)'==$(USERNAME)&lt;/span&gt;"&lt;span&gt; &lt;/span&gt;&lt;span&gt;Command&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;&amp;amp;quot;&lt;/span&gt;&lt;span&gt;$(VSINSTALLDIR)\vstsdb\deploy\vsdbcmd.exe&lt;/span&gt;&lt;span&gt;&amp;amp;quot;&lt;/span&gt;&lt;span&gt; &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;/Action:Deploy /ConnectionString:&lt;/span&gt;&lt;span&gt;&amp;amp;quot;&lt;/span&gt;&lt;span&gt;%(DbProj.DeployConnStr)&lt;/span&gt;&lt;span&gt;&amp;amp;quot;&lt;/span&gt;&lt;span&gt; /DeployToDatabase+ &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;/manifest:&lt;/span&gt;&lt;span&gt;&amp;amp;quot;&lt;/span&gt;&lt;span&gt;.%(DbProj.OutputPath)%(DbProj.ProjectName).deploymanifest&lt;/span&gt;&lt;span&gt;&amp;amp;quot;&lt;/span&gt;&lt;span&gt; /p:TargetDatabase=%(DbProj.DbName) &lt;br&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;/p:Build=&lt;/span&gt;&lt;span&gt;&amp;amp;quot;&lt;/span&gt;&lt;span&gt;from cmd line&lt;/span&gt;&lt;span&gt;&amp;amp;quot;&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;      &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt; &lt;span&gt;Target&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt; &lt;span&gt;Project&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Writing these scripts may appear to be laborious but they’ll save you heaps of time in the long run.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="4"&gt;Recommendation #13: Build and deploy to your development sandbox using scripts&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;i&gt;UPDATE: Upon reading this blog post Mordechai Danielov wrote a follow-up in which he published a useful script that builds a series of projects using Powershell. Its at &lt;/i&gt;&lt;a href="http://bitwisemnm.com/2012/01/03/building-your-database-solutions-outside-of-visual-studio/" target="_blank"&gt;&lt;i&gt;building your database solutions outside of Visual Studio&lt;/i&gt;&lt;/a&gt;&lt;i&gt;.&lt;/i&gt;&lt;/p&gt;  &lt;h1&gt;Useful links&lt;/h1&gt;  &lt;p&gt;Over the years I’ve collected some links to MSDN articles that have proved invaluable:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193409.aspx" target="_blank"&gt;Build and Deploy Databases to an Isolated Development Environment&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa833165.aspx#CommunityContent" target="_blank"&gt;An Overview of Database Build and Deployment&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dvdarchive/cc164243.aspx" target="_blank"&gt;Apply Test-Driven Development to your Database Projects&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193415.aspx" target="_blank"&gt;Walkthrough: Partition a Database Project by Using Composite Projects&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/bahill/archive/2009/03/23/right-sizing-the-master-dbschema-file-for-better-design-time-performance.aspx" target="_blank"&gt;Right sizing the master.dbschema file for better design time performance&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/dd483214.aspx#id0100036" target="_blank"&gt;Referencing for Shared Server-Level Objects&lt;/a&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;float:none;white-space:normal;orphans:2;widows:2;font-size-adjust:none;font-stretch:normal;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193258.aspx" target="_blank"&gt;How to: Prepare a Database for Deployment From a Command Prompt by Using VSDBCMD.EXE&lt;/a&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;h1&gt;Datadude bugs&lt;/h1&gt;  &lt;p&gt;Like any substantial piece of software datadude is not without bugs. Many of the issues I have found are concerned with the datadude interpreter not correctly parsing T-SQL code, here’s a list of some bugs that I have found down the years:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/688259/refactor-rename-in-schema-view-crashes-visual-studio" target="_blank"&gt;Under certain circumstances a Refactor-&amp;gt;Rename operation can crash Visual Studio&lt;/a&gt; (followed up &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/705676/would-like-feedback-on-a-bug-that-has-been-closed-as-wont-fix" target="_blank"&gt;here&lt;/a&gt;) &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/674391/datadude-valid-merge-syntax-causes-warnings#details" target="_blank"&gt;Valid T-SQL MERGE syntax can cause false warnings&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/668651/datadude-refactoring-applies-the-wrong-edits-to-unit-tests" target="_blank"&gt;Refactor-&amp;gt;Rename doesn’t work properly for database unit tests&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/657580/datadude-deploy-failure-something-to-do-with-triggers#details" target="_blank"&gt;Removal of triggers from your datadude project may, under certain circumstances, cause a failed deployment&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/635058/datadude-derived-table-with-the-same-alias-as-one-of-the-columns-in-that-derived-table-incorrectly-causes-a-warning#details" target="_blank"&gt;Rare naming circumstance can cause false warnings&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/624876/datadude-t-sql-parser-throws-warnings-for-valid-t-sql#details" target="_blank"&gt;Valid function definition containing a CTE can cause false warnings&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/606656/datadude-datadude-attempts-to-deploy-a-default-constraint-before-deploying-the-function-referenced-by-that-constraint" target="_blank"&gt;A default constraint is attempted to be deployed before a function referenced by that constraint – hence an error occurs&lt;/a&gt; (confirmed as fixed in VS2010 SP1) &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/605544/datadude-failure-to-recognise-operand-type-clash-when-using-table-types#details" target="_blank"&gt;Datadude doesn’t catch a type mismatch between a table-valued-parameter and a parameter passed to it&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/594309/datadude-datetime2-data-generator-doesnt-generate-unique-values-when-the-column-is-part-of-a-composite-key" target="_blank"&gt;DateTime2 Data generator doesn't generate unique values when the column is part of a composite key&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/592932/datadude-certain-db-unit-test-class-names-can-throw-errors-when-the-class-is-created" target="_blank"&gt;Unit test class files cannot contain periods&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/586040/datadude-valid-create-view-syntax-throws-errors#details" target="_blank"&gt;Valid CREATE VIEW definition throws errors&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/573824/datadude-unexplained-warnings-from-dbproj-project" target="_blank"&gt;MERGE syntax in a stored procedure creates false warnings&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Some of these bugs were reported a long time ago and may well have been fixed in later service packs.&lt;/p&gt;  &lt;h1&gt;Previous datadude blog posts&lt;/h1&gt;  &lt;p&gt;I have &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/tags/Datadude/default.aspx" target="_blank"&gt;blogged on datadude&lt;/a&gt; quite a bit in the past:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2011/11/21/workaround-for-datadude-deployment-bug.aspx"&gt;Workaround for datadude deployment bug – NullReferenceException&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2011/02/10/building-a-database-installer-with-wix-datadude-and-visual-studio-2010.aspx"&gt;Building a database installer with WiX, datadude and Visual Studio 2010&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2011/01/19/generate-multiple-sqlcmdvars-vars-in-your-database-projects.aspx"&gt;Generate multiple SqlCmdVars files in your database projects&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2011/01/17/querying-visual-studio-project-files.aspx"&gt;Querying Visual Studio project files using T-SQL and Powershell&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/10/19/maintaining-version-history-in-your-database-using-visual-studio-2010.aspx"&gt;Maintaining version history in your database using Visual Studio 2010&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/10/06/enforcing-naming-conventions-using-database-unit-testing.aspx"&gt;Enforcing naming conventions using database unit testing&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/09/18/experiences-from-writing-sp-cascadingdataviewer-db-unit-testing-and-code-distribution.aspx"&gt;Experiences from writing sp_CascadingDataViewer – DB unit testing and code distribution&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/09/14/some-thoughts-on-visual-studio-database-references-and-how-they-should-be-used-for-sql-server-bi.aspx"&gt;Some thoughts on Visual Studio database references and how they should be used for SQL Server BI&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/08/23/microsoft-publish-visual-studio-2010-database-project-guidance.aspx"&gt;Microsoft publish Visual Studio 2010 Database Project Guidance&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/08/20/setting-up-database-unit-testing-as-part-of-a-continuous-integration-build-process-vs2010-db-tools-datadude.aspx"&gt;Setting up database unit testing as part of a Continuous Integration build process [VS2010 DB Tools - Datadude]&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/07/21/a-strategy-for-managing-security-for-different-environments-using-the-database-development-tools-in-visual-studio-2010.aspx"&gt;A strategy for managing security for different environments using the Database Development Tools in Visual Studio 2010&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;h1&gt;Summing up&lt;/h1&gt;  &lt;p&gt;This has been an inordinately large blog post so if you’ve read this far – well done. For easy reference, here are all the recommendations that I have made:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Use Source Control and implement a Continuous Integration deployment &lt;/li&gt;    &lt;li&gt;Turn on Code Analysis &lt;/li&gt;    &lt;li&gt;When running your deployment in a test environment, run it more than once &lt;/li&gt;    &lt;li&gt;Maintain an automated history of your deployments &lt;/li&gt;    &lt;li&gt;Use Schema View in preference to Solution Explorer &lt;/li&gt;    &lt;li&gt;Any action in a Pre or Post-Deployment Script should use PRINT to state what has been done &lt;/li&gt;    &lt;li&gt;Output the value of all variables in your Pre-Deployment script &lt;/li&gt;    &lt;li&gt;Each database object should be defined in a dedicated file &lt;/li&gt;    &lt;li&gt;Time your deployments and output the timings &lt;/li&gt;    &lt;li&gt;All literal values should be stored in your .sqlcmdvars file &lt;/li&gt;    &lt;li&gt;Every developer should use the Isolated Dev Environment settings in order to author their code &lt;/li&gt;    &lt;li&gt;Use “Not in Build” to remove an object from your database &lt;/li&gt;    &lt;li&gt;Build and deploy to your development sandbox using scripts &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;I really hope this proves useful because its taken a good long while to get it published &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://sqlblog.com/blogs/jamie_thomson/wlEmoticon-smile_68C424BA.png"&gt; If you have any feedback then please let me know in the comments.&lt;/p&gt;  &lt;p&gt;Thanks for reading!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;@jamiet&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;* When I started writing this blog post the first sentence was “Over the past six months I have worked on two separate projects for customers that wanted to make use of Visual Studio 2010 Database projects to manage their database schema.” as opposed to what it is now: “Over the past eighteen months I have worked on four separate projects…” Yes, that’s how long its taken to write it! &lt;img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://sqlblog.com/blogs/jamie_thomson/wlEmoticon-smile_68C424BA.png"&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;      &lt;h1&gt;Appendix – An example CI configuration&lt;/h1&gt;  &lt;p&gt;&lt;i&gt;As stated above, an earlier draft of this blog post included full details of the CI configuration from one of the projects that I have worked on. Although it may repeat some of what has already been said I have included that text below.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;==============================================================&lt;/i&gt;&lt;/p&gt;  &lt;h2&gt;Introduction&lt;/h2&gt;  &lt;p&gt;This project has invested heavily in using a Continuous Integration (CI) approach to development. What that means, succinctly, is that whenever someone checks-in some code to our source control system an automated build process is kicked off that constructs our entire system from scratch on a dedicated server. CI is not a new concept but it is fairly rare that anyone applies the same rigour to their database objects as they do to so-called “application code” (e.g. the stuff written in .Net code) and on this project we have made a conscious decision to properly build our databases as part of the CI build.&lt;/p&gt;  &lt;p&gt;Datadude employs a &lt;i&gt;declarative&lt;/i&gt; approach to database development. In other words you define what you want database schema to look like and datadude will work out what it needs to do to your target in order to turn it into what you have defined. What this means in practice is that you only ever write CREATE … DDL statements rather than IF &amp;lt;object-exists&amp;gt; THEN ALTER …ELSE CREATE … statements which is what you may have done in the past.&lt;/p&gt;  &lt;p&gt;Here’s our CI environment setup:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;SubVersion (SVN) is being used for source control &lt;/li&gt;    &lt;li&gt;&lt;a href="http://hudson-ci.org/"&gt;Hudson&lt;/a&gt;, an open source CI server, is being used to orchestrate our whole CI environment. It basically monitors our SVN repository and when it spots a checked-in file, kicks off the CI build &lt;/li&gt;    &lt;li&gt;Our CI scripts (the stuff that actually does the work) are written using &lt;a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx"&gt;msbuild&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;We have 2 msbuild scripts:      &lt;ul&gt;       &lt;li&gt;Build.proj which is responsible for:          &lt;ul&gt;           &lt;li&gt;Compiling all our .Net website code &lt;/li&gt;            &lt;li&gt;Building/Compiling our datadude projects&amp;nbsp; (every datadude project file is a msbuild-compliant script) &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;        &lt;li&gt;Deploy.proj which is responsible for:          &lt;ul&gt;           &lt;li&gt;Restoring latest database backups from our production environment into our CI environment &lt;/li&gt;            &lt;li&gt;Deploying our built datadude projects on top of those restored backups &lt;/li&gt;            &lt;li&gt;Build a folder structure to hold all the artefacts that get deployed &lt;/li&gt;            &lt;li&gt;Creating folder shares &lt;/li&gt;            &lt;li&gt;Moving SSIS packages into folder structure &lt;/li&gt;            &lt;li&gt;Deploying SSRS reports to our SSRS server &lt;/li&gt;            &lt;li&gt;Deploy our Analysis Services cube definitions to our Analysis Server &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Both Build.proj and Deploy.proj get executed by our CI build &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Building datadude projects&lt;/h2&gt;  &lt;p&gt;Datadude makes it very easy to build datadude projects in a CI environment because they are already msbuild-compliant; its simply a call to the MSBuild task, passing in the location of the solution file as an argument. We use the Release configuration (although there is no particular reason for you to do the same – purely your choice):&lt;/p&gt;  &lt;div style="font-size:10pt;"&gt;   &lt;div style="padding:2px 5px;overflow:auto;"&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;Target&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Name&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Database&lt;/span&gt;"&lt;span&gt;&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;!--&lt;/span&gt;&lt;span&gt;Build database projects and copy output to staging &lt;/span&gt;&lt;span&gt;--&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;Message&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Text&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;*****Building database solution&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;MSBuild&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Projects&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;..\src\SQL\DatabaseSolution.sln&lt;/span&gt;"&lt;span&gt; &lt;/span&gt;&lt;span&gt;Properties&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;Configuration=Release&lt;/span&gt;"&lt;span&gt; /&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span&gt;Target&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;  &lt;p&gt;That’s it! The output from a datadude build includes a number of files but the most important one is a .dbschema file which is an XML representation of all the objects in your database.&lt;/p&gt;  &lt;h2&gt;Deploying the output from a built datadude project&lt;/h2&gt;  &lt;p&gt;This is a little more difficult. We *&lt;b&gt;could&lt;/b&gt;* simply use the MSBuild task to call our deployment script as we do for build script (see above) but the problem with that is that there are many pre-requisites (including datadude itself) and we don’t want to install Visual Studio and all the assorted paraphernalia onto our various environments. Instead we chose to make use of a command-line tool called &lt;a href="http://msdn.microsoft.com/en-us/library/dd193283.aspx"&gt;VSDBCMD.exe&lt;/a&gt; to deploy datadude projects. VSDBCMD does basically the same job as what happens if you were to right-click on a datadude project in Visual Studio and select “Deploy” i.e. It compares the output of a build (A) to the target database (B) and works out what it needs to do to make B look like A. It then produces a .sql script that will actually make those requisite changes, then goes and executes it.&lt;/p&gt;  &lt;p&gt;The difficulty comes in VSDBCMD.exe having its own list of file dependencies that are listed at MSDN article &lt;a href="http://msdn.microsoft.com/en-us/library/dd193258.aspx"&gt;How to: Prepare a Database for Deployment From a Command Prompt by Using VSDBCMD.EXE&lt;/a&gt;, thankfully a much smaller list then if we were using the MSBuild task.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_334B6295.png"&gt;&lt;img style="border-width:0px;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_11EBBCF9.png" width="581" height="389"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Some of those files, namely:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Sqlceer35en.dll &lt;/li&gt;    &lt;li&gt;Sqlceme35.dll &lt;/li&gt;    &lt;li&gt;Sqlceqp35.dll &lt;/li&gt;    &lt;li&gt;Sqlcese35.dll &lt;/li&gt;    &lt;li&gt;System.Data.SqlServerCe.dll &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;get installed with SQL Server CE. We bundle along the x86 &amp;amp; x64 installers for SQL Server CE along with all the rest of our deployment artefacts and then, as part of Deploy.proj, install them like so:&lt;/p&gt;  &lt;div style="font-size:10pt;"&gt;   &lt;div style="padding:2px 5px;overflow:auto;"&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;Exec&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Command&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;'&lt;span&gt;msiexec /passive /l* "$(SetupLogDirectory)\SSCERuntime_x86-ENU.log" /i "$(BuildDir)\Vendor\SSCERuntime_x86-ENU.msi"&lt;/span&gt;'&lt;span&gt; /&amp;gt;&lt;/span&gt;       &lt;br&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;Exec&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;Condition&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;"&lt;span&gt;$(X64)&lt;/span&gt;"&lt;span&gt; &lt;/span&gt;&lt;span&gt;Command&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;'&lt;span&gt;msiexec /passive /l* "$(SetupLogDirectory)\SSCERuntime_x64-ENU.log" /i "$(BuildDir)\Vendor\SSCERuntime_x64-ENU.msi"&lt;/span&gt;'&lt;span&gt; /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;  &lt;p&gt;That takes care of some of the dependencies but we still have to take care of:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;DatabaseSchemaProviders.Extensions.xml &lt;/li&gt;    &lt;li&gt;Microsoft.Data.Schema.dll &lt;/li&gt;    &lt;li&gt;Microsoft.Data.Schema.ScriptDom.dll &lt;/li&gt;    &lt;li&gt;Microsoft.Data.Schema.ScriptDom.Sql.dll &lt;/li&gt;    &lt;li&gt;Microsoft.Data.Schema.Sql.dll &lt;/li&gt;    &lt;li&gt;Microsoft.SqlServer.BatchParser.dll &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;as well as the actual VSDBCMD.exe file itself. Quite simply we keep those files in SVN and then bundle them along with all our deployment artefacts (I won’t show you how we do that because its out of the scope of this post and besides if you’re at all proficient with msbuild then you’ll know how to do that and if you’re not, well, why are you reading this?)&lt;/p&gt;  &lt;p&gt;&lt;i&gt;==============================================================&lt;/i&gt;&lt;/p&gt;</description></item><item><title>Workaround for datadude deployment bug - NullReferenceException</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2011/11/21/workaround-for-datadude-deployment-bug.aspx</link><pubDate>Mon, 21 Nov 2011 08:56:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:39903</guid><dc:creator>jamiet</dc:creator><description>
&lt;p&gt;I have come across a bug in Visual Studio 2010 Database Projects (&lt;a href="http://www.sqlservercentral.com/questions/tags/visual+studio/" target="_blank"&gt;aka datadude aka DPro aka Visual Studio Database Development Tools aka Visual Studio Team Edition for Database Professionals aka Juneau aka SQL Server Data Tools&lt;/a&gt;) that other people may encounter so, for the purposes of googling, I'm writing this blog post about it. Through my own googling I discovered that a Connect bug had already been raised about it (&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/693158/vs2010-database-project-deploy-sqldeploytask-task-failed-unexpectedly-nullreferenceexception#details" target="_blank"&gt;VS2010 Database project deploy - “SqlDeployTask” task failed unexpectedly, NullReferenceException&lt;/a&gt;), and coincidentally enough it was raised by my former colleague Tom Hunter (whom I have &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/11/25/sql-server-2008-sp1-cu-6-includes-small-changes-to-dtsx-files.aspx" target="_blank"&gt;mentioned here before as the superhuman Tom Hunter&lt;/a&gt;) although it has not (at this time) received a reply from Microsoft. Tom provided a repro, namely that this syntactically valid function definition:&lt;/p&gt;
&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;CREATE FUNCTION &lt;/span&gt;&lt;span style="color:black;"&gt;[dbo].[Function1]&lt;br&gt;&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;RETURNS TABLE&lt;br&gt;AS&lt;br&gt;RETURN &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;WITH &lt;/span&gt;&lt;span style="color:black;"&gt;cte &lt;/span&gt;&lt;span style="color:blue;"&gt;AS &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;&lt;span style="color:black;"&gt;1 &lt;/span&gt;&lt;span style="color:blue;"&gt;AS &lt;/span&gt;&lt;span style="color:black;"&gt;[c1]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;&lt;span style="color:black;"&gt;[$(Database3)].[dbo].[Table1]&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;&lt;span style="color:black;"&gt;1 &lt;/span&gt;&lt;span style="color:blue;"&gt;AS &lt;/span&gt;&lt;span style="color:black;"&gt;[c1]&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;&lt;span style="color:black;"&gt;cte&lt;br&gt;&lt;/span&gt;&lt;span style="color:gray;"&gt;) &lt;/span&gt;&lt;/code&gt;

&lt;p&gt;would produce this nasty unhelpful error upon deployment:&lt;br&gt;&lt;/p&gt;
&lt;font color="red"&gt;
&lt;p&gt;C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.TSqlTasks.targets(120,5): Error MSB4018: The "SqlDeployTask" task failed unexpectedly.&lt;br&gt;&lt;span style="font-weight:bold;"&gt;System.NullReferenceException: Object reference not set to an instance of an object&lt;/span&gt;.&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.Sql.SchemaModel.SqlModelComparerBase.VariableSubstitution(SqlScriptProperty propertyValue, IDictionary`2 variables, Boolean&amp;amp; isChanged)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.Sql.SchemaModel.SqlModelComparerBase.ArePropertiesEqual(IModelElement source, IModelElement target, ModelPropertyClass propertyClass, ModelComparerConfiguration configuration)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareProperties(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, ModelComparisonChangeDefinition changes)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareElementsWithoutCompareName(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, Boolean parentExplicitlyIncluded, Boolean compareElementOnly, ModelComparisonResult result, ModelComparisonChangeDefinition changes)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareElementsWithSameType(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, ModelComparisonResult result, Boolean ignoreComparingName, Boolean parentExplicitlyIncluded, Boolean compareElementOnly, Boolean compareFromRootElement, ModelComparisonChangeDefinition&amp;amp; changes)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareChildren(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, Boolean parentExplicitlyIncluded, Boolean compareParentElementOnly, ModelComparisonResult result, ModelComparisonChangeDefinition changes, Boolean isComposing)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareElementsWithoutCompareName(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, Boolean parentExplicitlyIncluded, Boolean compareElementOnly, ModelComparisonResult result, ModelComparisonChangeDefinition changes)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareElementsWithSameType(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, ModelComparisonResult result, Boolean ignoreComparingName, Boolean parentExplicitlyIncluded, Boolean compareElementOnly, Boolean compareFromRootElement, ModelComparisonChangeDefinition&amp;amp; changes)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareChildren(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, Boolean parentExplicitlyIncluded, Boolean compareParentElementOnly, ModelComparisonResult result, ModelComparisonChangeDefinition changes, Boolean isComposing)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareElementsWithoutCompareName(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, Boolean parentExplicitlyIncluded, Boolean compareElementOnly, ModelComparisonResult result, ModelComparisonChangeDefinition changes)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareElementsWithSameType(IModelElement sourceElement, IModelElement targetElement, ModelComparerConfiguration configuration, ModelComparisonResult result, Boolean ignoreComparingName, Boolean parentExplicitlyIncluded, Boolean compareElementOnly, Boolean compareFromRootElement, ModelComparisonChangeDefinition&amp;amp; changes)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareAllElementsForOneType(ModelElementClass type, ModelComparerConfiguration configuration, ModelComparisonResult result, Boolean compareOrphanedElements)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.SchemaModel.ModelComparer.CompareStore(ModelStore source, ModelStore target, ModelComparerConfiguration configuration)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.Build.SchemaDeployment.CompareModels()&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.Build.SchemaDeployment.PrepareBuildPlan()&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.Build.SchemaDeployment.Execute(Boolean executeDeployment)&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.Build.SchemaDeployment.Execute()&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Data.Schema.Tasks.DBDeployTask.Execute()&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()&lt;br&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean&amp;amp; taskResult)&lt;br&gt;&amp;nbsp;&amp;nbsp; Done executing task "SqlDeployTask" -- FAILED.&lt;br&gt;&amp;nbsp; Done building target "DspDeploy" in project "Lloyds.UKTax.DB.UKtax.dbproj" -- FAILED.&lt;br&gt;&amp;nbsp;Done executing task "CallTarget" -- FAILED.&lt;br&gt;Done building target "DBDeploy" in project &lt;br&gt;&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;It turns out there are a certain set of circumstances that need to be met for this error to occur:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The object being deployed is an inline function&amp;nbsp; (may also exist for multistatement and scalar functions - I haven't tested that)&lt;br&gt;&lt;/li&gt;

&lt;li&gt;That object includes SQLCMD variable references&lt;/li&gt;

&lt;li&gt;The object has already been deployed successfully&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just to reiterate that last bullet point, the error does not occur when you deploy the function for the first time, only on the subsequent deployment.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Luckily I have a direct line into a guy on the development team so I fired off an email on Friday evening and today (Monday) I received a reply back telling me that there is a simple fix, one simply has to remove the parentheses that wrap the SQL statement. So, in the case of Tom's repro, the function definition simply needs to be changed to:&lt;/p&gt;
&lt;p&gt;
&lt;code style="font-size:12px;"&gt;&lt;span style="color:blue;"&gt;CREATE FUNCTION &lt;/span&gt;&lt;span style="color:black;"&gt;[dbo].[Function1]&lt;br&gt;&lt;/span&gt;&lt;span style="color:gray;"&gt;()&lt;br&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;RETURNS TABLE&lt;br&gt;AS&lt;br&gt;RETURN &lt;/span&gt;&lt;span style="color:green;"&gt;--(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;WITH &lt;/span&gt;&lt;span style="color:black;"&gt;cte &lt;/span&gt;&lt;span style="color:blue;"&gt;AS &lt;/span&gt;&lt;span style="color:gray;"&gt;(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;&lt;span style="color:black;"&gt;1 &lt;/span&gt;&lt;span style="color:blue;"&gt;AS &lt;/span&gt;&lt;span style="color:black;"&gt;[c1]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;&lt;span style="color:black;"&gt;[$(Database3)].[dbo].[Table1]&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:gray;"&gt;)&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;SELECT &lt;/span&gt;&lt;span style="color:black;"&gt;1 &lt;/span&gt;&lt;span style="color:blue;"&gt;AS &lt;/span&gt;&lt;span style="color:black;"&gt;[c1]&lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color:blue;"&gt;FROM &lt;/span&gt;&lt;span style="color:black;"&gt;cte&lt;br&gt;&lt;/span&gt;&lt;span style="color:green;"&gt;--) &lt;/span&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;I have commented out the offending parentheses rather than removing them just to emphasize the point.
&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Thereafter the function will deploy fine. I tested this out on my own project this morning and can confirm that this fix does indeed work.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;I have been told that the bug CAN be reproduced in the Release Candidate (RC) 0 build of SQL Server Data Tools in SQL Server 2012 so am hoping that a fix makes it in for the Release-To-Manufacturing (RTM) build.&lt;/p&gt;

&lt;p&gt;Hope this helps&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@jamiet&lt;/a&gt; &lt;/p&gt;</description></item><item><title>Building a database installer with WiX, datadude and Visual Studio 2010</title><link>http://www2.sqlblog.com/blogs/jamie_thomson/archive/2011/02/10/building-a-database-installer-with-wix-datadude-and-visual-studio-2010.aspx</link><pubDate>Thu, 10 Feb 2011 21:45:17 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:33387</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;&lt;font size="3"&gt;Today I have been using Windows Installer XML (WiX) to build an installer (.msi file) that would install a SQL Server database on a server of my choosing; the source code for that database lives in datadude (a tool &lt;/font&gt;&lt;a href="http://www.sqlservercentral.com/questions/visual+studio/72236/" target="_blank"&gt;&lt;font size="3"&gt;which you may know by one of quite a few other names&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;). The basis for this work was a most excellent blog post by Duke Kamstra entitled &lt;/font&gt;&lt;a href="http://blogs.msdn.com/b/dukek/archive/2009/10/19/implementing-a-wix-installer-that-calls-the-gdr-version-of-vsdbcmd-exe.aspx" target="_blank"&gt;&lt;font size="3"&gt;Implementing a WIX installer that calls the GDR version of VSDBCMD.EXE&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; which coves the delicate intricacies of doing this – particularly how to call &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd193283.aspx" target="_blank"&gt;&lt;font size="3"&gt;Vsdbcmd.exe&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; in a &lt;/font&gt;&lt;a href="http://wix.sourceforge.net/manual-wix3/wix_xsd_customaction.htm" target="_blank"&gt;&lt;font size="3"&gt;CustomAction&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;. Unfortunately there are a couple of things wrong with Duke’s post:&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;font size="3"&gt;Searching for “datadude wix” didn’t turn it up in the first page of search results and hence it took me a long time to find it. And I knew that it existed. If someone else were after a post on using WiX with datadude its likely that they would never have come across Duke’s post and that would be a great shame because its the definitive post on the matter.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3"&gt;It was written in October 2009 and had not been updated for Visual Studio 2010.&lt;/font&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;font size="3"&gt;Well, this blog post is an attempt to solve those problems. Hopefully I’ve solved the first one just by following a few of &lt;/font&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/12/21/blogging-tips-for-sql-server-professionals.aspx" target="_blank"&gt;&lt;font size="3"&gt;my blogging SEO tips&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; while writing this blog post, in the rest of it I will explain how I took Duke’s code and updated it to work in Visual Studio 2010.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;If you need to build a database installer using WiX, datadude and Visual Studio 2010 then you still need to follow Duke’s blog post so go and do that now. Below are the amendments that I made that enabled the project to get built in Visual Studio 2010:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;font size="3" face="Calibri"&gt;In VS2010 datadude’s output files have changed from being called Database.&amp;lt;suffix&amp;gt; to &amp;lt;ProjectName&amp;gt;_Database.&amp;lt;suffix&amp;gt;. Duke’s code was referencing the old file name formats.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font face="Calibri"&gt;&lt;font size="3"&gt;Duke used $(var.SolutionDir) and relative paths to point to datadude artefacts I have replaced these with Votive Project References &lt;/font&gt;&lt;a href="http://wix.sourceforge.net/manual-wix3/votive_project_references.htm"&gt;&lt;font size="3"&gt;http://wix.sourceforge.net/manual-wix3/votive_project_references.htm&lt;/font&gt;&lt;/a&gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;I commented out all references to MicrosoftSqlTypesDbschema in DatabaseArtifacts.wxi. I don't think this is produced in VS2010 (I may be wrong about that but it wasn't in the output from my project)&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Similarly I commented out component MicrosoftSqlTypesDbschema in VsdbcmdArtifacts.wxi. It wasn't where Duke's code said it should have been so am assuming/hoping it isn't needed.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Duke's &lt;font face="Consolas"&gt;?define&lt;/font&gt; block to work out appropriate SrcArchPath actually wasn't working for me (i.e. &lt;font face="Consolas"&gt;&amp;lt;?if $(var.Platform)=x64 ?&lt;/font&gt;&amp;gt; was evaluating to false)&amp;#160; so I just took out the conditional stuff and declared the path explicitly to the “Program Files (x86)” path. The old code is still there though if you need to put it back.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;None of the &lt;font face="Consolas"&gt;&amp;lt;RegistrySearch&amp;gt;&lt;/font&gt; stuff is needed for VS2010 - so I commented it all out!&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Changed to use &lt;font face="Consolas"&gt;/manifest &lt;/font&gt;option rather than &lt;font face="Consolas"&gt;/model&lt;/font&gt; option on vsdbcmd.exe command-line. Personal preference is all!&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Added a new component in order to bundle along the vsdbcmd.exe.config file&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font size="3" face="Calibri"&gt;Made the install of the Custom Action dependent on the relevant feature being selected for install. This one is actually really important – deselecting the database feature for installation does not, by default, stop the CustomAction from executing and so would cause an error - so that scenario needs to be catered for&lt;/font&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;font size="3"&gt;I have made my amended solution available for download at: &lt;/font&gt;&lt;a title="http://cid-550f681dad532637.office.live.com/self.aspx/Public/BlogShare/20110210/InstallMyDatabase.zip" href="http://cid-550f681dad532637.office.live.com/self.aspx/Public/BlogShare/20110210/InstallMyDatabase.zip"&gt;&lt;font size="3"&gt;http://cid-550f681dad532637.office.live.com/self.aspx/Public/BlogShare/20110210/InstallMyDatabase.zip&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; It contains two projects: the WiX project and the datadude project that is the source to be deployed (for demo purposes it only contains one table).&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_640907F6.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4817D2FE.png" width="407" height="335" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;I have also made the .msi available although in order that it gets through file blockers I changed the name from InstallMyDatabase.msi to InstallMyDatabase.ms_ – simply rename the file back once you have downloaded it from: &lt;/font&gt;&lt;a title="http://cid-550f681dad532637.office.live.com/self.aspx/Public/BlogShare/20110210/InstallMyDatabase.ms%5E_" href="http://cid-550f681dad532637.office.live.com/self.aspx/Public/BlogShare/20110210/InstallMyDatabase.ms%5E_"&gt;&lt;font size="3"&gt;http://cid-550f681dad532637.office.live.com/self.aspx/Public/BlogShare/20110210/InstallMyDatabase.ms%5E_&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt; .You can try it out for yourself – the only thing it does is dump the files into %Program Files%\MyDatabase and uses them to install a database onto a server of your choosing with a name of your choosing - no damaging side-affects. I will caveat this by saying “it works on my machine” and, not having access to a plethora of different machines, I haven’t tested it anywhere else. One potential issue that I know of is that Vsdbcmd.exe has a &lt;a href="http://msdn.microsoft.com/en-us/library/dd193258.aspx" target="_blank"&gt;dependency on SQL Server CE&lt;/a&gt; although if you have SQL Server tools or Visual Studio installed you should be fine. Unfortunately its not possible to bundle along the SQL Server CE installer in the .msi because Windows will not allow you to call one installer from inside another – the recommended way to get around this problem is to build a bootstrapper to bundle the whole lot together but doing that is outside the scope of this blog post. If you discover any other issues then please let me know.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;Here are the screenshots from the installer:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_1879B472.png"&gt;&lt;font size="3"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7DCD1858.png" width="522" height="408" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_14ABE9D5.png"&gt;&lt;font size="3"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_2BF6EE46.png" width="522" height="408" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_029FA648.png"&gt;&lt;font size="3"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_15E05CE7.png" width="524" height="409" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_74148455.png"&gt;&lt;font size="3"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_322D9F07.png" width="524" height="410" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7765F630.png"&gt;&lt;font size="3"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0F1D2D97.png" width="524" height="409" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_141F6B46.png"&gt;&lt;font size="3"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_64814CB9.png" width="526" height="411" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;And once installed….&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7CEF886A.png"&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_109C71FF.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_2808D80F.png" width="322" height="191" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;Hope this is useful!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;&lt;font size="3"&gt;@jamiet&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;</description></item></channel></rss>