<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://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 'Continuous Integration'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Continuous+Integration&amp;orTags=0</link><description>Search results matching tag 'Continuous Integration'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Continuous deployment of SSDT database projects to Windows Azure using Team Foundation Service</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/01/27/continuous-deployment-of-ssdt-database-projects-to-windows-azure-using-team-foundation-service.aspx</link><pubDate>Sun, 27 Jan 2013 20:07:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47339</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;Continuous deployment is described by Wikipedia as:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Most CI systems allow the running of scripts after a build finishes. In most situations, it is possible to write a script to deploy the application to a live test server that everyone can look at. A further advance in this way of thinking is &lt;/em&gt;&lt;em&gt;Continuous Deployment&lt;/em&gt;&lt;em&gt;, which calls for the software to be deployed directly into production       &lt;br&gt;&lt;a title="http://en.wikipedia.org/wiki/Continuous_Integration" href="http://en.wikipedia.org/wiki/Continuous_Integration"&gt;http://en.wikipedia.org/wiki/Continuous_Integration&lt;/a&gt;&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I think of Continuous Deployment as a natural extension of Continuous Integration where not only do we build the source code, we deploy it as well. As I continue to put together my &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2013/01/15/my-sqlbits-pre-conference-seminar-ssdt-database-projects-from-the-ground-up.aspx"&gt;SSDT Database Projects from the ground-up&lt;/a&gt; seminar it occurred to me that demonstrating Continuous Deployment for SSDT database projects would be very useful. It then occurred to me that the recently released &lt;a href="http://tfs.visualstudio.com/"&gt;Team Foundation Service&lt;/a&gt; (TFS) includes a facility to build source code so I wondered, could one perhaps use TFS to build an SSDT database project and deploy it to a Windows Azure SQL Database (aka SQL Azure)? It turns out that the answer is “yes” and this blog provides a step-by-step guide to doing just that.&lt;/p&gt;  &lt;p&gt;Its worth noting that Team Foundation Service is free for up to five users. SSDT is also free. Windows Azure SQL Databases, however, are not free so you may have to pay a small amount to get one or alternatively adapt the steps herein to use Team Foundation Server to deploy to an on-premises SQL Server instance. Note that a MSDN subscription does include some small usage of Windows Azure SQL Database and that allowance will be more than enough to go through the steps herein.&lt;/p&gt;  &lt;p&gt;We can break our process down into the following high-level steps:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create a Windows Azure SQL Database&lt;/li&gt;    &lt;li&gt;Sign up for Team Foundation Service (TFS)&lt;/li&gt;    &lt;li&gt;Create an SSDT database project&lt;/li&gt;    &lt;li&gt;Add the SSDT project to TFS Source Control&lt;/li&gt;    &lt;li&gt;Setup your Publish Profile file&lt;/li&gt;    &lt;li&gt;Create a Build Definition&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s dive into all of those steps.&lt;/p&gt;  &lt;h3&gt;Create a new Windows Azure SQL Database&lt;/h3&gt;  &lt;p&gt;Visit &lt;a title="https://manage.windowsazure.com/" href="https://manage.windowsazure.com/"&gt;https://manage.windowsazure.com/&lt;/a&gt; and sign up for a new Windows Azure SQL Database:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_713EE18A.png"&gt;&lt;img width="675" height="183" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_6FFA48AB.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Your new database will be viewable in the portal immediately:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_43DD4BBA.png"&gt;&lt;img width="611" height="447" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_14AB6023.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Windows Azure SQL Databases are, by default, closed to the outside world so you must edit the list of IP addresses that are allowed to access the server. Setting this up is outside the scope of this blog post however simply go to &lt;a href="http://msdn.microsoft.com/en-us/library/ee621783.aspx" target="_blank"&gt;How to: Configure the Server-Level Firewall Settings (Windows Azure SQL Database)&lt;/a&gt; to learn how to do this (its very easy).&lt;/p&gt;  &lt;h3&gt;Sign up for Team Foundation Service&lt;/h3&gt;  &lt;p&gt;Visit &lt;a title="https://tfs.visualstudio.com/" href="https://tfs.visualstudio.com/"&gt;https://tfs.visualstudio.com/&lt;/a&gt; to sign up to use Team Foundation Service using your Microsoft Account (aka Windows Live ID). Once you have signed-up you will have a dedicated service URL (mine, for example,&amp;nbsp; is &lt;a href="https://jamiet.visualstudio.com/)."&gt;https://jamiet.visualstudio.com/).&lt;/a&gt; Visit that URL and click “New Team Project”:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0CB3BDC1.png"&gt;&lt;img width="673" height="202" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_59778457.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Fill in the pertinent details and hit “Create Project”:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7F6D34AD.png"&gt;&lt;img width="441" height="374" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_308C6F4E.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Creating the Team Project will take a minute or so but will be ready for you when you need it shortly.&lt;/p&gt;  &lt;h3&gt;Create an SSDT database project&lt;/h3&gt;  &lt;p&gt;For this you’re going to need SSDT for Visual Studio 2010 or Visual Studio 2012. They are both free and can be downloaded from &lt;a href="http://msdn.microsoft.com/en-us/data/gg427686" target="_blank"&gt;here&lt;/a&gt;; I am using SSDT for Visual Studio 2012.&lt;/p&gt;  &lt;p&gt;You will need to create a new SQL Server Database Project:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0F98FCA7.png"&gt;&lt;img width="765" height="432" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_07A15A45.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Once the project is created it will appear in Solution Explorer and be empty at this point. We are going to be deploying to Windows Azure SQL Database therefore we must tell the project that that will be the case. To do that right-click on the project and select Properties:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_623766D6.png"&gt;&lt;img width="459" height="146" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_21951A67.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In Project Settings select Windows Azure SQL Database as the Target platform:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_60869B02.png"&gt;&lt;img width="539" height="178" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_63B882EA.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You’ll need to add a database object to your project otherwise this is all rather pointless. Given that this is simply for demo purposes we shall simply create a table called [Table1].&lt;/p&gt;                  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_5097563E.png"&gt;&lt;img width="419" height="272" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5D91364F.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML4741cca_559993ED.png"&gt;&lt;img width="728" height="146" title="SNAGHTML4741cca" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="SNAGHTML4741cca" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML4741cca_thumb_4DA1F18B.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_1EDC38E9.png"&gt;&lt;img width="404" height="152" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0C273F32.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;OK, we now have a Windows Azure SQL Database, a TFS service (is that Team Foundation Service service???) and a SSDT database project with a simple table in it. Let’s now hook them all together.&lt;/p&gt;  &lt;h3&gt;Add the SSDT project to TFS Source Control&lt;/h3&gt;  &lt;p&gt;Interaction with TFS from within Visual Studio is done using the Team Explorer pane.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0B4ED948.png"&gt;&lt;img width="367" height="169" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0A76735E.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;From Team Explorer you will need to connect to your new TFS. Click on the address bar in Team Explorer and point to “Connect to Team Projects…”&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_1B7AA141.png"&gt;&lt;img width="501" height="352" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_488F8E0F.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Choose your project and click Connect. Your server is simply the name of the server that was setup earlier; remember that mine was jamiet.visualstudio.com (note that it uses an https connection, not http):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML48ae7f5_0061D233.png"&gt;&lt;img width="530" height="482" title="SNAGHTML48ae7f5" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="SNAGHTML48ae7f5" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML48ae7f5_thumb_6D40A586.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You should now be connected to your Team Foundation Service. Add your source code to TFS Source Control from inside Solution Explorer:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_2BC5F32D.png"&gt;&lt;img width="467" height="338" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0AD28086.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_3B858831.png"&gt;&lt;img width="347" height="469" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_487F6842.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;And check in your SSDT database project (or “commit” if you prefer that terminology):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_6E08E5A3.png"&gt;&lt;img width="348" height="285" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_3F432D01.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_5E19A0DF.png"&gt;&lt;img width="287" height="518" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_63F44478.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You will now be able to browse to your TFS home page (mine is &lt;a href="https://jamiet.visualstudio.com"&gt;https://jamiet.visualstudio.com&lt;/a&gt;), click on your project and browse through your checked in code:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_2279921F.png"&gt;&lt;img width="681" height="387" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_415005FD.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Setup your Publish Profile file&lt;/h3&gt;  &lt;p&gt;You need to tell SSDT where to deploy the project to, that information is stored in a &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/05/09/publish-profile-files-in-sql-server-data-tools-ssdt.aspx" target="_blank"&gt;Publish Profile file&lt;/a&gt;. In Solution Explorer right-click and select “Publish…”&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_78B6172B.png"&gt;&lt;img width="449" height="234" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_49F05E89.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Enter the details of the Windows Azure SQL Database that you prepared earlier:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_1DD36198.png"&gt;&lt;img width="597" height="338" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_75C0B278.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Once the Publish Profile file has been saved it will be saved in your project:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7B2F231C.png"&gt;&lt;img width="346" height="216" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0175F9AB.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;At the time of writing Windows Azure SQL Database only supports SQL authentication so we have to edit the Publish Profile file to include the password for the account that will be used for deployment. Right-click on the Publish Profile file, select “Open with…” and from the resultant dialog select “XML (Text) Editor:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_40677A46.png"&gt;&lt;img width="485" height="367" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_11A1C1A4.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Edit the Connection String to include your password:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7761587F.png"&gt;&lt;img width="720" height="168" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_417C6365.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;NOW you can check in:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_55294CF9.png"&gt;&lt;img width="334" height="279" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5450E70F.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_2114ADA6.png"&gt;&lt;img width="264" height="490" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_191D0B44.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;Create a Build Definition&lt;/h3&gt;  &lt;p&gt;A Build Definition defines how and when the source code in the project should get built. Create a new Build Definition by selecting “Builds” in the Team Explorer address bar and choosing New Build Definition:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_3EA688A5.png"&gt;&lt;img width="358" height="333" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_61F37D4A.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_4ED2509E.png"&gt;&lt;img width="244" height="182" title="image" style="margin:0px;border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0710C7B7.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Follow the steps shown in the screenshots below to setup your Build Definition:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7F192554.png"&gt;&lt;img width="623" height="426" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_3E0AA5F0.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_319C82C7.png"&gt;&lt;img width="625" height="428" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_5B9C80EF.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_55E16749.png"&gt;&lt;img width="623" height="427" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_46CA886F.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_172C69E3.png"&gt;&lt;img width="811" height="478" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7BA767DF.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;(Credit for informing me about the MSBuild arguments goes entirely to Jakob Ehn and his blog post &lt;a title="http://geekswithblogs.net/jakob/archive/2012/04/25/deploying-ssdt-projects-with-tfs-build.aspx" href="http://geekswithblogs.net/jakob/archive/2012/04/25/deploying-ssdt-projects-with-tfs-build.aspx"&gt;Deploying SSDT Projects with TFS Build&lt;/a&gt;)&lt;/p&gt; &lt;/blockquote&gt;  &lt;h3&gt;And you’re done!&lt;/h3&gt;  &lt;p&gt;If you have set everything up correctly then any future check in should trigger a build and thus a Publish of the SSDT project to your Windows Azure SQL Database. Here is my first build report:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_52BC52D6.png"&gt;&lt;img width="490" height="407" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_78B2032C.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;and back in SSDT I can use SQL Server Object Explorer to browse my newly deployed table:&lt;/p&gt;  &lt;blockquote&gt;&lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_053FB049.png"&gt;&lt;img width="374" height="425" title="image" style="border:0px currentColor;padding-top:0px;padding-right:0px;padding-left:0px;display:inline;background-image:none;" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4F5ABB2E.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;That’s Continuous Deployment for SSDT projects to Windows Azure SQL Database using Team Foundation Service. Awesome!&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>Implementing SQL Server solutions using Visual Studio 2010 Database Projects – a compendium of project experiences</title><link>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</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>SSIS MSBuild task now included in MSBuild Extension Pack</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/09/14/ssis-msbuild-task-now-included-in-msbuild-extension-pack.aspx</link><pubDate>Tue, 14 Sep 2010 21:11:55 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:28772</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;The information in this blog post may be of interest to anyone out there that is using Continuous Integration with msbuild in order to build/deploy a project that includes SSIS packages.&lt;/p&gt;  &lt;p&gt;The MSBuild Extension Pack at &lt;a href="http://msbuildextensionpack.codeplex.com/"&gt;http://msbuildextensionpack.codeplex.com/&lt;/a&gt; now includes an MSBuild task that will build an SSIS project, the output from which is a .deploymentmanifest file that can be used in concert with the SSIS deployment utility.&lt;/p&gt;  &lt;p&gt;Building a SSIS project using the SSIS MSBuild Task essentially has the same effect as right-clicking on a SSIS project and selecting Build with CreateDeploymentUtility=True (i.e. produces a .deploymentmanifest file):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7FED67F0.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="build ssis project" border="0" alt="build ssis project" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_48C3D9F7.png" width="304" height="367" /&gt;&lt;/a&gt;&amp;#160;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_7B473769.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="SSIS Deployemnt Utility" border="0" alt="SSIS Deployemnt Utility" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_03E78FF6.png" width="653" height="339" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The advantage of using the MSBuild task is of course that you can now do it in an MSBuild script, none of this manual mouse-clicking required thank you very much!&lt;/p&gt;  &lt;p&gt;The SSIS MSBuild task was previously available in the SSIS community samples project at &lt;a href="http://sqlsrvintegrationsrv.codeplex.com"&gt;http://sqlsrvintegrationsrv.codeplex.com&lt;/a&gt; but having it as part of the MSBuild Extension Pack is definitely advantageous as this is a very widely used set of utilities. The source code has been available in the MSBuild Extension pack since &lt;a href="http://msbuildextensionpack.codeplex.com/SourceControl/changeset/changes/54481" target="_blank"&gt;changeset 54481&lt;/a&gt; which was checked-in on 26th August 2010 and was included in the &lt;a href="http://msbuildextensionpack.codeplex.com/releases/view/46020" target="_blank"&gt;August 2010 Release&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Note that in order to deploy your packages after using the SSIS MSBuild task you will need to call the SSIS deployment utility and pass in the outputted .deploymentmanifest file. Information on doing that is decidedly thin on the ground so I’ll try and elucidate. The SSIS Deployment Utility is an executable that gets installed with SQL Server Integration Services workstation tools and is called dtsinstall.exe. You can call it on the command-line and pass in the path to a .deploymentmanifest file but as far as I can determine there is no way to do an unattended install (i.e. there is no way to tell dtsinstall.exe where to install the packages to, it simply opens up a GUI and prompts you for this information). This is a horribly antiquated method of deployment and I’m hunting around to see if there’s anything I’ve missed here – if you know any better please let me know.&lt;/p&gt;  &lt;p&gt;Hope this helps!&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>Setting up database unit testing as part of a Continuous Integration build process [VS2010 DB Tools - Datadude]</title><link>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</link><pubDate>Fri, 20 Aug 2010 18:41:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:28103</guid><dc:creator>jamiet</dc:creator><description>&lt;P&gt;&lt;I&gt;&lt;FONT face=Consolas&gt;[This blog post assumes a familiarity with the terms Continuous Integration (CI), MSBuild &amp;amp; MSTest. If you don’t have a good appreciation of those terms then this blog post probably isn’t for you anyway so don’t worry about it!]&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Over the past few days I have been working to get database unit tests executing as part of our Continuous Integration (CI) build and in this blog post I’ll explain how I went about it because it is decidedly &lt;I&gt;not&lt;/I&gt; straightforward.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;We are using the &lt;STRONG&gt;DB Tools in Visual Studio 2010&lt;/STRONG&gt; (aka &lt;STRONG&gt;DBPro&lt;/STRONG&gt; or &lt;STRONG&gt;Datadude&lt;/STRONG&gt; - I will refer to it as Datadude from here on in) which includes unit testing functionality. The rest of this blog post also assumes a familiarity with database unit testing in Datadude although if you want to do some background reading an excellent place to start is Jamie Laflen’s whitepaper &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/magazine/cc164243.aspx"&gt;&lt;FONT face=Consolas&gt;Apply Test-Driven Development to your Database Projects&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Consolas&gt; on MSDN.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Consolas&gt;
&lt;HR&gt;
&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;We got to the point where we had a C# test project containing database unit tests that executed successfully inside Visual Studio. For demonstration purposes I have put together a solution that contains a simple database project and a test project containing a database unit test:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image001_png01CB4075_1B0AD4EE.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="Solution Explorer screenshot" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=433 alt="solution explorer" src="http://sqlblog.com/blogs/jamie_thomson/cid_image001_png01CB4075_thumb_7DC4E149.png" width=506 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;And just to prove that the test executes successfully in Visual Studio:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image002_png01CB4075_10D5E829.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="Visual Studio Test Results screenshot" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=249 alt="Visual Studio Test Results screenshot" src="http://sqlblog.com/blogs/jamie_thomson/cid_image002_png01CB4075_thumb_1DCFC83A.png" width=856 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;N.B. The code for the database object(s) and the unit test itself are not important, that is outside the scope of this blog post.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;At this point we have some tests that run in our development sandbox, the configuration for which is done using the Database Test Configuration dialog:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image003_png01CB4076_14938CF9.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="database test configuration choice" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=382 alt="database test configuration choice" src="http://sqlblog.com/blogs/jamie_thomson/cid_image003_png01CB4076_thumb_057CAE1F.png" width=786 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image004_png01CB4076_70AAB59E.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="database test configuration dialog" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=638 alt="database test configuration dialog" src="http://sqlblog.com/blogs/jamie_thomson/cid_image004_png01CB4076_thumb_4FB742F7.png" width=508 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Those config settings are stored in the app.config file which exists as part of our test project (screenshot of which is at the top of this blog post). If we take a look inside that file we can see the&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;ConnectionString&lt;/FONT&gt; &lt;FONT face=Consolas&gt;that we defined in the Database Test Configuration dialog:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image005_png01CB4076_5F76D7FB.png"&gt;&lt;IMG title="app config connectionString DatabaseUnitTesting" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=271 alt="app config connectionString DatabaseUnitTesting" src="http://sqlblog.com/blogs/jamie_thomson/cid_image005_png01CB4076_thumb_17491C1F.png" width=959 border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Note the&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#c0504d&gt;DatabaseUnitTesting&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT face=Consolas&gt;element, we’re going to be coming back to that a little later!!&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Consolas&gt;
&lt;HR&gt;
&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Once we have the tests running in Visual Studio the next step is to get them running inside a CI build and for that we call out to MSTest.exe from inside an MSBuild script:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image006_png01CB407D_54F603DB.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="msbuild script mstest" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=155 alt="msbuild script mstest" src="http://sqlblog.com/blogs/jamie_thomson/cid_image006_png01CB407D_thumb_733FF92A.png" width=1069 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;When we execute that script we get some positive results and all looks peachy:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image007_png01CB407D_380C1D5F.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="msbuild mstest output" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=534 alt="msbuild mstest output" src="http://sqlblog.com/blogs/jamie_thomson/cid_image007_png01CB407D_thumb_4837E558.png" width=650 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;FONT face=Consolas&gt;
&lt;HR&gt;
&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;OK, we now have a test that runs successfully both in Visual Studio and by calling MSTest.exe directly from MSBuild. The problem I have to solve now though (and this is the real crux of this blog post) is that the test is still running against the server I specified in app.config; I don’t want this, I want the test to run against a server of my choosing, namely my build server. For this I had to call on the help of the aforementioned Jamie Laflen (who, luckily, I have met in the past) and he gave me guidance on how to achieve it. Below are the steps that you need to take.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Firstly you need to tell Datadude that you want to specify some different credentials and that is done by adding an attribute&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;&lt;FONT color=#ff0000&gt;AllowConfigurationOverride&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;"&lt;/FONT&gt;&lt;FONT face=Consolas&gt; to the&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#c0504d&gt;DatabaseUnitTesting&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT face=Consolas&gt;element of app.config like so:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image008_png01CB407E_32F9B9E3.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="app config DatabaseUnitTesting AllowConfigurationOverride" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=345 alt="app config DatabaseUnitTesting AllowConfigurationOverride" src="http://sqlblog.com/blogs/jamie_thomson/cid_image008_png01CB407E_thumb_23E2DB09.png" width=643 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;I&gt;&lt;FONT face=Consolas&gt;Don’t forget to build your test project after changing the app.config file!!!&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;This will cause datadude unit testing framework to go and search for a file called&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;*.dbunittest.config&lt;/FONT&gt; &lt;FONT face=Consolas&gt;where the * indicates either:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Consolas&gt;The name of machine upon which the tests are being run or&lt;/FONT&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Consolas&gt;The name of the user running the tests&lt;/FONT&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;According to Jamie L datadude runs the following precedence checks:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Consolas&gt;Is an override specified in app.config? If not, use app.config&lt;/FONT&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Consolas&gt;Does an override file exist called &amp;lt;machinename&amp;gt;.dbunittest.config? If so, use it, if not…&lt;/FONT&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Consolas&gt;Does an override file exist called &amp;lt;username&amp;gt;.dbunittest.config? If so, use it, if not…&lt;/FONT&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Consolas&gt;Fail!&lt;/FONT&gt; &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;“So”, you may be asking, “what goes in this &lt;/FONT&gt;&lt;FONT face="Courier New"&gt;*.dbunittest.config&lt;/FONT&gt; file then?”. &lt;FONT face=Consolas&gt;Fair question, that’s where the&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#c0504d&gt;DatabaseUnitTesting&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT face=Consolas&gt;element that I mentioned earlier comes in. Copy that element from the app.config file into your &lt;FONT face="Courier New"&gt;*.dbunittest.config&lt;/FONT&gt; file, remove the&lt;/FONT&gt;&amp;nbsp;&lt;FONT face="Courier New"&gt;&lt;FONT color=#ff0000&gt;AllowConfigurationOverride&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;"&lt;/FONT&gt;&lt;FONT face=Consolas&gt; attribute and change the&lt;/FONT&gt; &lt;FONT face="Courier New"&gt;ConnectionString&lt;/FONT&gt; &lt;FONT face=Consolas&gt;property accordingly:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image009_png01CB4081_20ED7656.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="dbunittest.config ConnectionString" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=236 alt="dbunittest.config ConnectionString" src="http://sqlblog.com/blogs/jamie_thomson/cid_image009_png01CB4081_thumb_7464466F.png" width=847 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;The next step is to tell MSTest.exe that there is another file that it needs to be aware of when it runs the tests and to do that we need to create a custom testsettings file that will be used instead of the default Local.testsettings. To create a new testsettings file use the Add New Item dialog:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image010_png01CB4083_7D049EFB.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="add new test settings" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=466 alt="add new test settings" src="http://sqlblog.com/blogs/jamie_thomson/cid_image010_png01CB4083_thumb_1BDB12DA.png" width=825 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;In the Test Settings dialog go to ‘Deployment’, click ‘Enable deployment’, then ‘Add File…’. Browse to your&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; *.dbunittest.config &lt;/FONT&gt;&lt;FONT face=Consolas&gt;file and add it to the project:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image011_png01CB4083_39D920CE.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="test settings dialog" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=655 alt="test settings dialog" src="http://sqlblog.com/blogs/jamie_thomson/cid_image011_png01CB4083_thumb_3FB3C467.png" width=892 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;At this point you’re good to go and all you need to do edit your call to MSTest.exe and tell it to use your new testsettings file:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image012_png01CB4084_5CD96C71.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="msbuild script mstest testsettings" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=163 alt="msbuild script mstest testsettings" src="http://sqlblog.com/blogs/jamie_thomson/cid_image012_png01CB4084_thumb_70865605.png" width=1011 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Notice the extra information in the output:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image013_png01CB4084_2F0BA3AC.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="msbuild script output" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=577 alt="msbuild script output" src="http://sqlblog.com/blogs/jamie_thomson/cid_image013_png01CB4084_thumb_4DE2178A.png" width=702 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;You’ll have to trust me that it used the new config file and therefore the new &lt;/FONT&gt;&lt;FONT face="Courier New"&gt;ConnectionString&lt;/FONT&gt;&lt;FONT face=Consolas&gt;, although having said that you do get some useful information in the test results file (*.trx) that MSTest.exe creates:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/cid_image014_png01CB4085_248ACF8C.png"&gt;&lt;FONT face=Consolas&gt;&lt;IMG title="mstest test results trx output" style="BORDER-TOP-WIDTH:0px;PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;BORDER-LEFT-WIDTH:0px;BACKGROUND-IMAGE:none;BORDER-BOTTOM-WIDTH:0px;PADDING-TOP:0px;BORDER-RIGHT-WIDTH:0px;" height=255 alt="mstest test results trx output" src="http://sqlblog.com/blogs/jamie_thomson/cid_image014_png01CB4085_thumb_2A657325.png" width=991 border=0&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;FONT face=Consolas&gt;
&lt;HR&gt;
&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;I think its fair to say that this process is a little fiddly to say the least so I’m hoping that Microsoft come up with a better solution in the future, one that integrates better into the whole testing infrastructure. Meanwhile you can download the demo that I put together for this blog post from my &lt;/FONT&gt;&lt;A href="http://bit.ly/cYYIdq" target=_blank&gt;&lt;FONT face=Consolas&gt;SkyDrive&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Consolas&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Hope that helps! Comments are welcome.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://twitter.com/jamiet" target=_blank&gt;&lt;FONT face=Consolas&gt;Jamiet&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;SPAN class=Apple-style-span style="WORD-SPACING:0px;FONT:medium 'Times New Roman';TEXT-TRANSFORM:none;TEXT-INDENT:0px;WHITE-SPACE:normal;LETTER-SPACING:normal;BORDER-COLLAPSE:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;&lt;SPAN class=Apple-style-span style="FONT-SIZE:13px;FONT-FAMILY:Arial, Helvetica, sans-serif;"&gt;
&lt;P&gt;UPDATE: Atul Verma has written a 3-part blog series on how to write your database unit tests so if Jamie Laflen's whitepaper (linked to above) doesn't tickle your fancy try reading Atul's series instead:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/b/atverma/archive/2010/07/28/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010.aspx"&gt;How to unit test SQL Server 2008 database using Visual Studio 2010&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-2.aspx"&gt;How to unit test SQL Server 2008 database using Visual Studio 2010 – Part 2&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A class="" href="http://blogs.msdn.com/b/atverma/archive/2010/08/22/how-to-unit-test-sql-server-2008-database-using-visual-studio-2010-part-3.aspx"&gt;How to unit test SQL Server 2008 database using Visual Studio 2010 – Part 3&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;</description></item></channel></rss>