<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Home of the Data Dude</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/gertd/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/gertd/feed.xml</link>
    <description>Welcome to the blog where the DataDude talks about SQL Server Data Tools and Visual Studio Database Projects</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:21:07 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Schema View for SQL Server Data Tools</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/schema-view-for-sql-server-data-tools</link>
      <pubDate>Mon, 02 Apr 2012 11:29:47 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2012/04/02/schema-view-for-sql-server-data-tools/</guid>
      <description><![CDATA[Today the team released the first version of the SQL Server Data Tools – Power Tools, which adds the...]]></description>
      <content:encoded><![CDATA[<p>Today the team released the first version of the SQL Server Data Tools – Power Tools, which adds the ability to navigate the schema of your project inside the SQL Server Object Explorer.</p>  <p>Blog post detailing the release: <a title="https://blogs.msdn.com/b/ssdt/archive/2012/04/02/first-release-of-ssdt-power-tools.aspx" href="https://blogs.msdn.com/b/ssdt/archive/2012/04/02/first-release-of-ssdt-power-tools.aspx">https://blogs.msdn.com/b/ssdt/archive/2012/04/02/first-release-of-ssdt-power-tools.aspx</a></p>  <p>SSDT Power Tools installation location: <a title="https://visualstudiogallery.msdn.microsoft.com/9b0228c6-15d1-44de-9279-66dde12bf861?SRC=Featured" href="https://visualstudiogallery.msdn.microsoft.com/9b0228c6-15d1-44de-9279-66dde12bf861?SRC=Featured">https://visualstudiogallery.msdn.microsoft.com/9b0228c6-15d1-44de-9279-66dde12bf861?SRC=Featured</a></p>  <p>Please check it out,   <br />@DataDude </p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Connections Spring 2012</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/sql-connections-spring-2012</link>
      <pubDate>Fri, 23 Mar 2012 14:17:43 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2012/03/23/sql-connections-spring-2012/</guid>
      <description><![CDATA[Next week, at the SQL Server Connections conference, I will be presenting “Database Development...]]></description>
      <content:encoded><![CDATA[<p><a href="https://sharepoint/sites/dpevan/denali/2012-03-SqlConnections/"><img alt="SQL Connections Spring 2012" src="https://sharepoint/sites/dpevan/denali/2012-03-SqlConnections/Document%20Library/1/S12_IllBeThere_SQL.jpg" /></a></p>  <p>Next week, at the <a href="https://www.devconnections.com/" target="_blank">SQL Server Connections</a> conference, I will be presenting “Database Development with SQL Server Data Tools”, a 60 minute overview how you can leverage SQL Server Data Tools (SSDT) for your daily database development and deployment tasks.</p>  <p>When: Tuesday March 27th 2012, 10:00-11:00AM </p>  <p>Abstract:</p>  <table style="color: rgb(0, 0, 0);" cellspacing="0" cellpadding="2" width="864" border="1"><tbody>     <tr>       <td valign="top" width="862">         <p><b>SMS01: Database Development with SQL Server Data Tools</b>            <br /><a href="https://www.devconnections.com/shows/sp2012/speakers.aspx?s=185&amp;sp=1543">Gert Drapers</a>            <br />SQL Server Data Tools (SSDT) transforms traditional database development by introducing a declarative, model-based experience that supports both online and offline (project-based) database development. This session introduces SSDT and shows through a series of demos how you can develop, debug, refactor, and maintain SQL Server and SQL Azure databases from within a single integrated environment</p>       </td>     </tr>   </tbody></table>  <p>Drop by if you are there!</p>  <p>@DataDude</p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Data Tools Released, Available Today!</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/sql-server-data-tools-released-available-today</link>
      <pubDate>Tue, 06 Mar 2012 17:43:07 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2012/03/06/sql-server-data-tools-released-available-today/</guid>
      <description><![CDATA[Today we released the first official release of the “SQL Server Data Tools” (SSDT) to the web. Even...]]></description>
      <content:encoded><![CDATA[<p>Today we released the first official release of the “SQL Server Data Tools” (SSDT) to the web. Even though this release accompanies SQL Server 2012 RTM, you can use SSDT against SQL Server 2005 or later, including SQL Azure. So <a href="https://msdn.microsoft.com/en-us/data/hh297027" target="_blank">download it now!</a> and get started developing and deploying your SQL Server databases using SQL Server Data Tools.</p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Developers Tools code-named “Juneau” becomes SQL Server Data Tools (SSDT)</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/sql-server-developers-tools-code-named-juneau-becomes-sql-server-data-tools-ssdt</link>
      <pubDate>Mon, 17 Oct 2011 12:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2011/10/17/sql-server-developers-tools-code-named-juneau-becomes-sql-server-data-tools-ssdt/</guid>
      <description><![CDATA[Last week at the SQL PASS SUMMIT 2011 in Seattle, Ted Kummert announced during his keynote that the...]]></description>
      <content:encoded><![CDATA[<p>Last week at the <a href="https://www.sqlpass.org/summit/2011/" target="_blank">SQL PASS SUMMIT 2011</a> in Seattle, <a href="https://www.sqlpass.org/summit/2011/SummitContent/Keynotes.aspx#Ted_Kummert" target="_blank">Ted Kummert</a> announced during his <a href="https://www.sqlpass.org/summit/2011/Live/LiveStreaming/LiveStreamingWednesday.aspx" target="_blank">keynote</a> that the final name of SQL Server Developers Tools code-named “Juneau” will be SQL Server Data Tools or SSDT for short. Additionally, the final name for SQL Server “Denali” will be SQL Server 2012.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/79/metablogapi/4113.SSDTLogo_thumb_45BD4441.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-79-metablogapi/4113.SSDTLogo_5F00_thumb_5F00_45BD4441.png"><img style="margin: 5px 1px 5px 5px; border: 0px currentcolor; float: right; display: inline; background-image: none;" title="SSDTLogo_thumb" border="0" alt="SSDTLogo_thumb" align="right" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/79/metablogapi/4604.SSDTLogo_thumb_thumb_495B5F1E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-79-metablogapi/4604.SSDTLogo_5F00_thumb_5F00_thumb_5F00_495B5F1E.png" width="154" height="154" /></a>Besides the final name there were other important data points shared at the PASS Summit regarding SSDT:</p>  <ul>   <li>SSDT will be broadly available as a free component of the SQL Server platform for all SQL Server users.</li>    <ul>     <li>SSDT targets: SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 and SQL Azure</li>      <li>SSDT will update with releases of SQL Azure, which means every 4-6 months</li>   </ul>    <li>SSDT will be initially released with SQL Server 2012</li>    <ul>     <li>SSDT with SQL Server 2012 will be hosted in the Visual Studio 2010 SP1 shell. It will install standalone or combine with existing Visual Studio 2010 Professional SP1 or higher installations</li>   </ul>    <li>SSDT will also ship with the next major release of Visual Studio</li>    <ul>     <li>In the next major Visual Studio release, SSDT will replace and provide conversion capability for existing Visual Studio database projects</li>      <li>You can preview this change in the <a href="https://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=27543">Microsoft® Visual Studio® 11 Developer Preview</a> which was released at the //Build conference in September 2011</li>   </ul>    <li>SSDT full versions and updates will be available online using the Web Platform Installer (<a href="https://www.microsoft.com/download/en/details.aspx?id=6164">WebPI</a>)</li>    <ul>     <li>SSDT installation will provide an administrative install experience to create a sharable setup which can be placed on a USB thumb drive or internal file share behind your firewall</li>   </ul> </ul>  <p>For more information, check out the <a href="https://skydrive.live.com/view.aspx?cid=526EB9977609D51E&amp;resid=526EB9977609D51E%211568">slides</a> from our PASS Summit breakout session <a href="https://www.sqlpass.org/summit/2011/Speakers/CallForSpeakers/SessionDetail.aspx?sid=1913">Database Development with SQL Server Data Tools Code-Named “Project Juneau” [AD-213-M]</a>.</p>  <p>So when can you get it? </p>  <p>Well you have to wait till SQL Server 2012 is released. The good news is that you can check out <a href="https://msdn.microsoft.com/data/hh297027">CTP3</a> today and we will provide updated bits in Q4 of CY2011 for you to evaluate. Watch the SSDT <a href="https://social.msdn.microsoft.com/Forums/en-US/ssdt/threads" target="_blank">MSDN forum</a> and the <a href="https://blogs.msdn.com/b/ssdt/" target="_blank">team blog</a> for more details in the coming weeks. </p>  <p>Thanks,    <br />Gert Drapers (@DataDude)     <br />Principal Group Program Manager     <br />SQL Server Data Tools (#SQLDataTools)</p>  <p><a href="https://msdn.microsoft.com/data/tools">https://msdn.microsoft.com/data/tools</a></p>]]></content:encoded>
    </item>
    <item>
      <title>VSDB Common Pitfalls 1</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/vsdb-common-pitfalls-1</link>
      <pubDate>Sat, 18 Dec 2010 18:08:26 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2010/12/18/vsdb-common-pitfalls-1/</guid>
      <description><![CDATA[Symptom: The resulting database deployment script always creates the database  This seems to be a...]]></description>
      <content:encoded><![CDATA[<h1>Symptom: The resulting database deployment script always creates the database</h1>  <p>This seems to be a common problem users are struggling with like illustrated by the following set of forum <a href="https://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/184af3b8-e24f-4156-8c93-4870aaed039c">post</a>. A user creates a database project, imports an existing database, builds and deploys. The resulting script always performs a CREATE DATABASE, why?</p>  <p>The answer is very simple, by default there is no target database connection defined, the deployment detects this and instead of failing, it assumes the target database therefore does not exist and creates a deployment script which will create the database.</p>  <p>Lets walk through the sequence of events:</p>  <ol>   <li>Create a new database project, open the project properties and go to the Deploy tab      <br />      <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/79/metablogapi/2234.image_7321554F.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-65-79-metablogapi/2234.image_5F00_7321554F.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/79/metablogapi/8816.image_thumb_4D4B2EEC.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-65-79-metablogapi/8816.image_5F00_thumb_5F00_4D4B2EEC.png" width="754" height="380" /></a>       <br />      <br />As you can see the target connection is empty.       <br /></li>    <li>Import a database schema from an existing database. What most users expect, is when they import from an existing database, either as part of the New project izard or by using the “Import Database Objects and Settings…” option that the connection used will become the target connection, however this is not the case. The reason for this is because we do not want to incidentally override the database you import from.&#160; <br /></li>    <li>Build and deploy the database project. The last step is to build and deploy the project. When doing this using the default settings you will get presented the following output in the Output Window      <br />      <br />      <table border="0" cellspacing="0" cellpadding="2" width="750"><tbody>         <tr>           <td valign="top" width="748">             <p><font face="Consolas">------ Build started: Project: mydb, Configuration: Debug Any CPU ------                  <br />&#160; mydb -&gt; d:\users\gert drapers\documents\visual studio 2010\Projects\mydb\sql\debug\mydb.dbschema                   <br />------ Deploy started: Project: mydb, Configuration: Debug Any CPU ------                   <br />&#160;&#160;&#160; Deployment script generated to:                   <br />d:\users\gert drapers\documents\visual studio 2010\Projects\mydb\sql\debug\mydb.sql</font></p>              <p><font face="Consolas">&#160;&#160;&#160; The deployment script was generated, but was not deployed. You can change the deploy action on the Deploy tab of the project properties.                  <br />========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========                   <br />========== Deploy: 1 succeeded, 0 failed, 0 skipped ========== </font></p>           </td>         </tr>       </tbody></table>      <br /></li>    <li>Switch the deploy action to: “Create a deployment scripts (.sql) and deploy to the database”. By default the “Deploy” action only creates a deployment script and does not deploy it to a database.      <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/79/metablogapi/6355.image_17D26CC7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-65-79-metablogapi/6355.image_5F00_17D26CC7.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/65/79/metablogapi/7838.image_thumb_135BEC00.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-65-79-metablogapi/7838.image_5F00_thumb_5F00_135BEC00.png" width="754" height="392" /></a>       <br /></li>    <li>Now Deploy again and it will fail, but why?      <br />      <table border="0" cellspacing="0" cellpadding="2" width="754"><tbody>         <tr>           <td valign="top" width="752">             <p><font face="Consolas">------ Build started: Project: mydb, Configuration: Debug Any CPU ------                  <br />&#160;&#160;&#160; Loading project files...                   <br />&#160;&#160;&#160; Building the project model and resolving object interdependencies...                   <br />&#160;&#160;&#160; Validating the project model...                   <br />&#160;&#160;&#160; Writing model to mydb.dbschema...                   <br />&#160; mydb -&gt; d:\users\gert drapers\documents\visual studio 2010\Projects\mydb\sql\debug\mydb.dbschema                   <br />------ Deploy started: Project: mydb, Configuration: Debug Any CPU ------                   <br />mydb.dbschema(0,0): <font style="background-color: #ffff00"><strong>Error TSD01234: Before you can deploy a database, you must specify a connection string in the project properties or at a command prompt.                      <br /></strong></font>&#160;&#160; Done executing task &quot;SqlDeployTask&quot; -- FAILED.                   <br />&#160; Done building target &quot;DspDeploy&quot; in project &quot;mydb.dbproj&quot; -- FAILED.                   <br />Done executing task &quot;CallTarget&quot; -- FAILED.                   <br />Done building target &quot;DBDeploy&quot; in project &quot;mydb.dbproj&quot; -- FAILED.                   <br />Done building project &quot;mydb.dbproj&quot; -- FAILED.</font></p>              <p><font face="Consolas">Build FAILED.                  <br />========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========                   <br />========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========</font></p>           </td>         </tr>       </tbody></table>     <font face="Consolas">       <p align="left"><font face="Segoe UI">So somewhere hidden inside an error message&#160; “Error TSD01234: Before you can deploy a database, <strong><u><em><font style="background-color: #ffff00">you must specify a connection string</font></em></u></strong> in the project properties or at a command prompt.”, you will find that the connection string was not defined.</font></p>     </font></li> </ol> <font face="Consolas">   <p align="left"></p>   <font face="Consolas"><font face="Segoe UI">Now most users will not change the “Deploy action” because they first want to see what the deployment engine will produce, so they are at a complete loss and will never find out why they are not getting want they expect.</font></font></font>  <h1>Summary:</h1>  <ul>   <li>If you want a incremental deployment script, the deployment engine must be able to perform a comparison between the project and the target database, which is identified via the “Target connection” setting on the project Deploy tab. </li>    <li>When you do not specify a target connection no errors nor warnings will get raised when the deployment engine only generates a deployment script which is the default setting. </li> </ul>  <p>I hope this dissolves one of the common VSDB pitfalls.</p>  <p>GertD @ <a href="https://dbproj.com">DBProj.com</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Let’s pick up blogging again…</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/lets-pick-up-blogging-again</link>
      <pubDate>Sat, 18 Dec 2010 17:34:40 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2010/12/18/lets-pick-up-blogging-again/</guid>
      <description><![CDATA[Sorry it has been really quiet on this blog for a while now, new job and new projects get in the...]]></description>
      <content:encoded><![CDATA[<p>Sorry it has been really quiet on this blog for a while now, new job and new projects get in the way. However when going through the <a href="https://social.msdn.microsoft.com/forums/en-US/vstsdb/threads/">MSDN forum</a> for Visual Studio Database Projects it seems there is a need for more hands-on examples and understanding about how the system works and behaves. Besides that it seems that the documentation is either missing, unclear or unread about many things, since it seems that everybody is having to solve many of the problems over and over again. Therefore it seemed like a good idea to create a series of common pitfall when using the Visual Studio Database Projects.</p>  <p>If you have any suggestions for topics please use the send email link on this blogs to pass on your suggestions. I hope you will find this useful.</p>  <p>GertD at DBPrioj.com</p>]]></content:encoded>
    </item>
    <item>
      <title>DefaultDataPath</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/defaultdatapath</link>
      <pubDate>Mon, 30 Nov 2009 17:48:10 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2009/11/30/defaultdatapath/</guid>
      <description><![CDATA[VSDB uses the the ($DefaultDataPath) SQLCMD variable to represent the location where you would place...]]></description>
      <content:encoded><![CDATA[<p>VSDB uses the the ($DefaultDataPath) SQLCMD variable to represent the location where you would place your data and log file of your database. The deployment engine sets the value of SQLCMD variable by querying SQL Server using the following query:</p>  <div class="csharpcode">   <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">DECLARE</span> @<span class="kwrd">value</span> nvarchar(512),</pre>
</div>

<div class="csharpcode">
  <pre><span class="lnum">   2:  </span>        @rc    <span class="kwrd">int</span>;</pre>
</div>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">EXEC</span>    @rc = [master].[dbo].[xp_instance_regread] N<span class="str">'HKEY_LOCAL_MACHINE'</span>,N<span class="str">'Software\Microsoft\MSSQLServer\MSSQLServer'</span>,N<span class="str">'DefaultData'</span>, @<span class="kwrd">value</span> <span class="kwrd">output</span><span class="rem">-- , 'no_output'; </span></pre>
</div>

<div class="csharpcode">
  <pre><span class="lnum">   4:  </span><span class="kwrd">SELECT</span>  @<span class="kwrd">value</span> <span class="kwrd">AS</span> [<span class="kwrd">Value</span>]</pre>
</div>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>&#160;</p>

<p>The problem is that this value by default is not getting populated when you install SQL Server! You have to set it using SQL Server Management Studio, using the Server properties dialog, on the Database Settings tab,&#160; you will find the “Database default locations”.</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/DefaultDataPath_F342/image_2.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/DefaultDataPath_F342/image_2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/DefaultDataPath_F342/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/DefaultDataPath_F342/image_thumb.png" width="753" height="675" /></a> </p>

<p>You can programmatically set it using the following query:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">EXEC</span> xp_instance_regwrite N<span class="str">'HKEY_LOCAL_MACHINE'</span>, N<span class="str">'Software\Microsoft\MSSQLServer\MSSQLServer'</span>, N<span class="str">'DefaultData'</span>, REG_SZ, N<span class="str">'d:\dbs\MSSQL10.MSSQLSERVER\MSSQL\DATA'</span></pre>
</div>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p>This brings up the next question, what does VSDB return as the value if the DefaultData location Registry entry is not set? It returns the location of the master.mdf file. If you would turn on SQL tracing you will see the following query fly by:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">DECLARE</span> @filepath nvarchar(260),</pre>

  <pre><span class="lnum">   2:  </span>        @rc <span class="kwrd">int</span></pre>

  <pre class="alt"><span class="lnum">   3:  </span>&#160;</pre>

  <pre><span class="lnum">   4:  </span><span class="kwrd">EXEC</span> master.dbo.xp_instance_regread N<span class="str">'HKEY_LOCAL_MACHINE'</span>,N<span class="str">'Software\Microsoft\MSSQLServer\MSSQLServer'</span>,N<span class="str">'DefaultData'</span>, @filepath <span class="kwrd">output</span>, <span class="str">'no_output'</span> </pre>

  <pre class="alt"><span class="lnum">   5:  </span>&#160;</pre>

  <pre><span class="lnum">   6:  </span><span class="kwrd">IF</span> ((@filepath <span class="kwrd">IS</span> <span class="kwrd">NOT</span> <span class="kwrd">NULL</span>) <span class="kwrd">AND</span> (CHARINDEX(N<span class="str">'\'</span>, @filepath, len(@filepath)) = 0))</pre>

  <pre class="alt"><span class="lnum">   7:  </span>    <span class="kwrd">SELECT</span>     @filepath = @filepath + N<span class="str">'\'</span></pre>

  <pre><span class="lnum">   8:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   9:  </span><span class="kwrd">IF</span> (@filepath <span class="kwrd">IS</span> <span class="kwrd">NULL</span>)</pre>

  <pre><span class="lnum">  10:  </span>    <span class="kwrd">SELECT</span>     @filepath = [sdf].[physical_name]</pre>

  <pre class="alt"><span class="lnum">  11:  </span>    <span class="kwrd">FROM</span>       [master].[sys].[database_files] <span class="kwrd">AS</span> [sdf]</pre>

  <pre><span class="lnum">  12:  </span>    <span class="kwrd">WHERE</span>      [file_id] = 1</pre>

  <pre class="alt"><span class="lnum">  13:  </span>&#160;</pre>

  <pre><span class="lnum">  14:  </span><span class="kwrd">SELECT</span> @filepath <span class="kwrd">AS</span> FilePath</pre>
</div>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>&#160;</p>

<p>Now this still does not mean it works, because SQL Server or SQL Server Management Studio<em> <strong><u>not</u></strong></em> validate if this location actually exists and is accessible from within SQL Server. </p>

<p>So the question becomes how can you protect yourself against this inside my deployment? </p>

<p>The following script can be helpful as a pre-deployment script to check if the $(DefaultDataPath) location actually exists and take action accordingly. </p>

<p><a href="https://cid-526eb9977609d51e.skydrive.live.com/self.aspx/DataDude/Samples/Scripts/DataPathExistsCheck.sql" target="_blank">DataPathExistsCheck.sql</a></p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="rem">-- If we raise an error we want to stop execution of the deployment engine</span></pre>

  <pre><span class="lnum">   2:  </span>:<span class="kwrd">ON</span> ERROR <span class="kwrd">EXIT</span></pre>

  <pre class="alt"><span class="lnum">   3:  </span>&#160;</pre>

  <pre><span class="lnum">   4:  </span><span class="kwrd">SET</span> NOCOUNT <span class="kwrd">ON</span></pre>

  <pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">DECLARE</span> @<span class="kwrd">value</span> nvarchar(512),</pre>

  <pre><span class="lnum">   6:  </span>        @rc    <span class="kwrd">int</span>;</pre>

  <pre class="alt"><span class="lnum">   7:  </span><span class="kwrd">EXEC</span>    @rc = [master].[dbo].[xp_instance_regread] N<span class="str">'HKEY_LOCAL_MACHINE'</span>,N<span class="str">'Software\Microsoft\MSSQLServer\MSSQLServer'</span>,N<span class="str">'DefaultData'</span>, @<span class="kwrd">value</span> <span class="kwrd">output</span><span class="rem">-- , 'no_output'; </span></pre>

  <pre><span class="lnum">   8:  </span><span class="rem">-- debug: shows the output</span></pre>

  <pre class="alt"><span class="lnum">   9:  </span><span class="rem">-- SELECT  @value AS [Value], @rc as [RC];</span></pre>

  <pre><span class="lnum">  10:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  11:  </span><span class="kwrd">DECLARE</span> @<span class="kwrd">result</span> <span class="kwrd">int</span></pre>

  <pre><span class="lnum">  12:  </span><span class="kwrd">DECLARE</span> @<span class="kwrd">table</span> <span class="kwrd">as</span> <span class="kwrd">table</span>(FileExists <span class="kwrd">int</span>, DirExist <span class="kwrd">int</span>, ParentDirExists <span class="kwrd">int</span>)</pre>

  <pre class="alt"><span class="lnum">  13:  </span><span class="rem">-- debug: shows the output</span></pre>

  <pre><span class="lnum">  14:  </span><span class="rem">-- EXEC [master].[dbo].[xp_fileexist] @value</span></pre>

  <pre class="alt"><span class="lnum">  15:  </span>INSERT  @<span class="kwrd">table</span> <span class="kwrd">EXEC</span> [master].[dbo].[xp_fileexist] @<span class="kwrd">value</span></pre>

  <pre><span class="lnum">  16:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  17:  </span><span class="kwrd">IF</span> <span class="kwrd">EXISTS</span> (<span class="kwrd">SELECT</span> * <span class="kwrd">FROM</span> @<span class="kwrd">table</span> <span class="kwrd">WHERE</span> DirExist = 1)</pre>

  <pre><span class="lnum">  18:  </span><span class="kwrd">BEGIN</span></pre>

  <pre class="alt"><span class="lnum">  19:  </span>    <span class="kwrd">PRINT</span> <span class="str">' DIRECTORY '</span> + @<span class="kwrd">value</span> + <span class="str">' EXISTS'</span></pre>

  <pre><span class="lnum">  20:  </span><span class="kwrd">END</span></pre>

  <pre class="alt"><span class="lnum">  21:  </span><span class="kwrd">ELSE</span></pre>

  <pre><span class="lnum">  22:  </span><span class="kwrd">BEGIN</span></pre>

  <pre class="alt"><span class="lnum">  23:  </span>    <span class="kwrd">PRINT</span> <span class="str">' DIRECTORY '</span> + @<span class="kwrd">value</span> + <span class="str">' DOES NOT EXIST'</span></pre>

  <pre><span class="lnum">  24:  </span>    <span class="kwrd">RAISERROR</span>(<span class="str">'DIRECTORY DOES NOT EXIST'</span>, 16, 1)</pre>

  <pre class="alt"><span class="lnum">  25:  </span><span class="kwrd">END</span></pre>

  <pre><span class="lnum">  26:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  27:  </span>:<span class="kwrd">ON</span> ERROR <span class="kwrd">IGNORE</span> </pre>
</div>
<style type="text/css">

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>&#160;</p>

<p>I hope this is helpful and builds a better understanding on how VSDB works under the covers, 
  <br />GertD @ <a href="https://www.DBProj.com">www.DBProj.com</a></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server 2008 R2</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/sql-server-2008-r2</link>
      <pubDate>Tue, 24 Nov 2009 13:26:20 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2009/11/24/sql-server-2008-r2/</guid>
      <description><![CDATA[Now that SQL Server 2008 R2 November CTP is available, I found some time to install it and test the...]]></description>
      <content:encoded><![CDATA[<p>Now that <a href="https://www.microsoft.com/sqlserver/2008/en/us/R2Downloads.aspx" target="_blank">SQL Server 2008 R2 November CTP</a> is available, I found some time to install it and test the existing Visual Studio 2008 Team System Database Edition GDR R2 release with it. The only thing that is really different from a SQL Server point of view besides two changes to the SQL parser, is that the version number changed from 10.00.xxxx to 10.50.yyyy (10.00.2531 for the November CTP). As we will see enough to confuse the VSDB 2008 GDR R2 release.</p>  <p>First step, is to create a connection inside Solution Explorer, no problems here, I can create a connection, navigate the schema using Solution Explorer, use the table and query designer tools. Next step is to create a project. In this case I created a SQL Server 2008 Database project named sql2008r2. </p>  <h1>Import Database Schema</h1>  <p>The next step is to import a schema from the SQL Server 2008 R2 instance, using the Import Database Schema option, beforehand I created an instance of the good old Northwind database on the SQL Server 2008 R2 instance, named Northwind. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_2.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_thumb.png" width="743" height="558" /></a></p>  <p>The problems start after hitting the Start option, or if you were using the new project wizard to create the project and import the schema in a single step, you would face the problem after hitting the Start button inside the wizard.</p>  <p>The problem manifests itself as follows:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_10.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_10.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_thumb_4.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_thumb_4.png" width="743" height="559" /></a> </p>  <p>The change in version number blocks the Import Database Schema code to connect to the SQL Server 2008 R2 instance, since it presents itself with a 10.50.yyyy instead of the 10.00.xxxx version number.</p>  <p>&#160;</p>  <h1>Schema Compare</h1>  <p>Now we have an empty project, so lets attempt to use Schema Compare, and compare the SQL Server 2008 R2 database (as the source) with the project as the target.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_12.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_12.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_thumb_5.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/SQLServer2008R2_B5C2/image_thumb_5.png" width="741" height="354" /></a> </p>  <p>This works great, not problems! You only need to make sure that you select all the object types you want to include. By default permissions and extended properties are excluded from the comparison and would therefore not get imported.</p>  <h1>Deploy</h1>  <p>Now we have a project, lets deploy it to a new database. In first instance this failed, because Schema Compare does not parameterize the file definitions of the database, so I had to update these, as shown below.</p>  <p>Updated file definitions:</p>  <div class="csharpcode">   <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">ALTER</span> <span class="kwrd">DATABASE</span> [$(DatabaseName)]</pre>

  <pre><span class="lnum">   2:  </span>    <span class="kwrd">ADD</span> <span class="kwrd">FILE</span> (NAME = [$(DatabaseName)_data], FILENAME = <span class="str">'$(DefaultDataPath)\$(DatabaseName).mdf'</span>, <span class="kwrd">SIZE</span> = 3328 KB, MAXSIZE = UNLIMITED, FILEGROWTH = 1024 KB) <span class="kwrd">TO</span> FILEGROUP [<span class="kwrd">PRIMARY</span>];</pre>

  <pre class="alt"><span class="lnum">   3:  </span>&#160;</pre>

  <pre><span class="lnum">   4:  </span><span class="kwrd">ALTER</span> <span class="kwrd">DATABASE</span> [$(DatabaseName)]</pre>

  <pre class="alt"><span class="lnum">   5:  </span>    <span class="kwrd">ADD</span> LOG <span class="kwrd">FILE</span> (NAME = [$(DatabaseName)_log], FILENAME = <span class="str">'$(DefaultDataPath)\$(DatabaseName).ldf'</span>, <span class="kwrd">SIZE</span> = 832 KB, MAXSIZE = 2097152 MB, FILEGROWTH = 10 %);</pre>

  <pre><span class="lnum">   6:  </span>&#160;</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p></p>

<p></p>

<p></p>

<p></p>

<p>After this deploy and incremental deploy works as expected, without any problems. Next steps were to test Data Compare, Data Generation and Database Unit Testing, which all worked as expected as well.</p>

<p>So besides the glitch in Import Database Schema, SQL Server 2008 R2 and the VS 2008 Database Edition GDR R2 get along just fine, good to know.</p>

<p>GertD @ <a href="https://www.DBProj.com">www.DBProj.com</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Pre and Post Deployment Events</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/pre-and-post-deployment-events</link>
      <pubDate>Tue, 13 Oct 2009 14:33:39 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2009/10/13/pre-and-post-deployment-events/</guid>
      <description><![CDATA[Visual Studio makes it relatively easy to hook in to pre and post build events, by using the Project...]]></description>
      <content:encoded><![CDATA[<p>Visual Studio makes it relatively easy to hook in to pre and post build events, by using the Project properties tab named Build Events. However when using Database Projects (.dbproj) you more often need to do something at deployment time. The good news is that the standard MSBuild framework, already defines these events, the bad news is that you manually have to update the project file yourself.</p>  <p>The steps are pretty simple:</p>  <ul>   <li>Unload the project, by right clicking on the project node inside Solution Explorer and selecting the “Unload Project” option </li>    <li>This will grey-out the project node inside Solution Explorer and mark it (unavailable). Now you can right click on it again and select the “Edit &lt;your project file name&gt;.dbproj” option. This will load the project file inside the XML editor. </li>    <li>Next you have to add the target elements for the PreDeployEvent and PostDeployEvent, like below: </li> </ul>  <div class="csharpcode">   <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">&lt;</span><span class="html">Target</span> <span class="attr">Name</span><span class="kwrd">=&quot;PreDeployEvent&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre><span class="lnum">   2:  </span>    <span class="kwrd">&lt;</span><span class="html">Message</span> <span class="attr">Importance</span><span class="kwrd">=&quot;high&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;Pre deployment event&quot;</span><span class="kwrd">/&gt;</span></pre>

  <pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">&lt;/</span><span class="html">Target</span><span class="kwrd">&gt;</span></pre>

  <pre><span class="lnum">   4:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">&lt;</span><span class="html">Target</span> <span class="attr">Name</span><span class="kwrd">=&quot;PostDeployEvent&quot;</span> <span class="kwrd">&gt;</span></pre>

  <pre><span class="lnum">   6:  </span>    <span class="kwrd">&lt;</span><span class="html">Message</span> <span class="attr">Importance</span><span class="kwrd">=&quot;high&quot;</span> <span class="attr">Text</span><span class="kwrd">=&quot;Post deployment event&quot;</span><span class="kwrd">/&gt;</span></pre>

  <pre class="alt"><span class="lnum">   7: </span> <span class="kwrd">&lt;/</span><span class="html">Target</span><span class="kwrd">&gt;</span></pre>
</div>
<style type="text/css">



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>&#160;</p>

<ul>
  <li>After you made all the changes, you save and close the project file and reload the project, by right clicking on the project node again and choosing the “Reload Project” option. </li>

  <ul>
    <li>If you forgot to close the editor, you will be asked if it can be closed and saved. Only after you confirmed this is OK, the project will be reloaded. </li>
  </ul>

  <li>Now you can test if your pre and post-deployment events are firing by deploying your project. If everything works you should see the pre and post build event messages in the output window like on lines 9 and 14. </li>
</ul>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span>------ Build started: Project: nw, Configuration: Debug Any CPU ------</pre>

  <pre><span class="lnum">   2:  </span>    Loading project references...</pre>

  <pre class="alt"><span class="lnum">   3:  </span>    Loading project files...</pre>

  <pre><span class="lnum">   4:  </span>    Building the project model and resolving object interdependencies...</pre>

  <pre class="alt"><span class="lnum">   5:  </span>    Validating the project model...</pre>

  <pre><span class="lnum">   6:  </span>    Writing model to nw.dbschema...</pre>

  <pre class="alt"><span class="lnum">   7:  </span>  nw -<span class="kwrd">&gt;</span> D:\demo\nw\sql\debug\nw.dbschema</pre>

  <pre><span class="lnum">   8:  </span>------ Deploy started: Project: nw, Configuration: Debug Any CPU ------</pre>

  <pre class="alt"><span class="lnum">   9:  </span>  <strong>Pre deployment event</strong></pre>

  <pre><span class="lnum">  10:  </span>    Deployment script generated to:</pre>

  <pre class="alt"><span class="lnum">  11:  </span>D:\demo\nw\sql\debug\nw.sql</pre>

  <pre><span class="lnum">  12:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  13:  </span>    The deployment script was generated, but was not deployed. You can change the deploy action on the Deploy tab of the project properties.</pre>

  <pre><span class="lnum">  14:  </span>  <strong>Post deployment event</strong></pre>

  <pre class="alt"><span class="lnum">  15:  </span>========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========</pre>

  <pre><span class="lnum">  16:  </span>========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========</pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Now you should be able to hook-up your events to the pre and post deployment events. Please keep in mind that <a href="https://blogs.msdn.com/gertd/archive/2009/09/14/pre-deployment-scripts.aspx" target="_blank">pre-deployment scripts do not change the outcome of deployments</a> like discussed earlier in this blog post. </p>

<p>Success,
  <br /><a href="mailto:GertD@DBProj.com">GertD @ DBProj.com</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Pre-Deployment Scripts</title>
      <link>https://docs.microsoft.com/archive/blogs/gertd/pre-deployment-scripts</link>
      <pubDate>Mon, 14 Sep 2009 16:48:00 GMT</pubDate>
      <dc:creator><![CDATA[Gert Drapers (MSFT)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gertd/2009/09/14/pre-deployment-scripts/</guid>
      <description><![CDATA[Pre-deployment script do not change the outcome of deployments!  The above statements is something...]]></description>
      <content:encoded><![CDATA[<h1>Pre-deployment script do not change the outcome of deployments!</h1>  <p>The above statements is something that most users do not realize when using pre-deployment scripts. Since the pre-deployment script is included in to the deployment script, it therefore by definition runs after the comparison the the source model with the target database (model), and therefore cannot change the behavior of the deployment.</p>  <h2>For example:</h2>  <p>If you know you have an orphaned object that is blocking a certain upgrade scenario,&#160; most users expect that when you would drop the offending object in a pre-deployment script, that this would take care of things. However the deployment engine has already performed the comparison between the source model and the target database (model) and generated the deployment script based on the results.</p>  <p>In order to gain a better understanding about what is going on, lets step through the flow of activities inside the deployment engine.</p>  <ol>   <li>The deployment engine takes as input the result of a build. It will de-serialize the source model (.dbschema) file to hydrate the source model representation in memory. It will take in to account the settings provided through the various configuration files, like Database.sqldeployment, Database.sqlsettings and Database.sqlcmdvars.      <br /></li>    <li>The second step is to create a target model representation, by importing the target database.      <br />Note: when the deployment engine detects that the target database does not exists, it will create a target model based on the model database, since SQL Server inherits all settings and objects inside the model database when creating a new database.       <br /></li>    <li>If a “Transaction.refactorlog” file is present, the refactorting operation will be applied to the models, by making changes to the target model to yield the correct outcome.      <br /></li>    <li>Then the two models are compared, in order to determine the differences between the source and target. Internally this results in to a set of all the differences, which are then represented in a tokenized format to represent each change, after which the tokenized stream of difference operations is ordered and optimized by folding/collapsing operations together. All this results in the actual deployment part of the script.      <br /></li>    <li>Once the previous step has been completed the single file deployment script representation is generated, which contains the following code blocks:      <br /><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/PreDeploymentScripts_9570/image_4.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/PreDeploymentScripts_9570/image_4.png" mce_href="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/PreDeploymentScripts_9570/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/gertd/WindowsLiveWriter/PreDeploymentScripts_9570/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/PreDeploymentScripts_9570/image_thumb_1.png" width="244" height="154" mce_src="https://blogs.msdn.com/blogfiles/gertd/WindowsLiveWriter/PreDeploymentScripts_9570/image_thumb_1.png" /></a>       <ol>       <li>The database code block contains the statements that either creates the database or checks if the database exists, based on the determination of the deployment engine. </li>        <li>The pre-deployment code block, contains the consolidated code, by flattening all the include statements (:r filename) inside the pre-deployment master script file. </li>        <li>The deployment code block is the code generated based on the model diff </li>        <li>The post-deployment code block, contains the consolidated code, by flattening all the include statements (:r filename) inside the post-deployment master script file. </li>        <li>The refactoring code block is maintaining the __RefactorLog table to indicate that a certain refactoring operation has been deployed to this instance. </li>     </ol>   </li> </ol>  <p>Now that we better understand the order in which operations take place, we can conclude that “pre-deployment scripts can never change the outcome of a deployment”, and that we really need a pre-pre-deployment script that runs before the model comparison is taking place in order to influence the outcome of the comparison and therefore the outcome of the deployment engine.</p>  <p>GertD @ <a href="https://www.DBProj.com" mce_href="https://www.DBProj.com">www.DBProj.com</a> <font color="#404040">(aetk39ypwb)</font></p>]]></content:encoded>
    </item>
  </channel>
</rss>