<?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 tags 'SSDT' and 'sql server'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SSDT,sql+server&amp;orTags=0</link><description>Search results matching tags 'SSDT' and 'sql server'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Connected development in SSDT versus SSMS</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/03/19/connected-development-in-ssdt-versus-ssms.aspx</link><pubDate>Tue, 19 Mar 2013 16:28:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:48314</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;When you install the database projects template of SSDT you get SQL Server Object Explorer (SSOX) installed as well. SSOX is a pane within Visual Studio and is the main enabler of the Connected Development experience that the SSDT team have attempted to provide.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML15dc3f62_18DB391E.png"&gt;&lt;img title="SNAGHTML15dc3f62" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;display:inline;" border="0" alt="SNAGHTML15dc3f62" width="335" height="118" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML15dc3f62_thumb_0C6D15F5.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;SSOX provides some really cool capabilities that are not in SQL Server Management Studio (I hope to blog about them in the near future). In theory these capabilities make it possible for a database developer to spend all their time in SSDT (i.e. Visual Studio) thus making SSMS a pureplay DBA tool (this does of course depend on your definition of both a database developer and a DBA, but I’m not getting into that debate here).&lt;/p&gt;  &lt;p&gt;With that in mind I have spent a few days trying to work without SSMS, preferring to live wholly inside Visual Studio instead. By and large I was able to do everything I needed to do from within Visual Studio however there were a few nuances about the experience that kept pushing me back to SSMS, I detail those nuances below.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;hr&gt;  &lt;h3&gt;Server groups&lt;/h3&gt;  &lt;p&gt;SSOX combines the functions of SSMS’s Object Explorer and Registered Servers pane. I don’t mind either way of working but it does mean that there is no ability to group servers in SSOX like you can in the Registered Servers pane&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_568820DA.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" width="244" height="97" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4E907E78.png"&gt;&lt;/a&gt;&amp;nbsp;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_0977B142.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" width="244" height="230" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_6C8E8C6C.png"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h3&gt;F6&lt;/h3&gt;  &lt;p&gt;In SSMS I regularly use the F6 keyboard shortcut to jump between the query, results &amp;amp; messages panes of a query window. No such keyboard shortcut exists in SSDT and they’ve already canned &lt;a target="_blank" href="https://connect.microsoft.com/sqlserver/feedback/details/780990/ssdt-f6-to-move-between-panes-in-a-query-window#tabs"&gt;my request on Connect to get this fixed&lt;/a&gt; (even though it laughably has status “closed as fixed”).&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;i&gt;UPDATE: See the comments below where Brett Gerhardi informed me of a different keyboard shortcut that does the same thing as F6. Actually its not quite the same, if you have multiple resultsets in your results pane then the behaviour is slightly different to F6 in SSMS - but that's not an issue you'll hot frequently.&lt;/i&gt;&lt;/p&gt;  &lt;h3&gt;Change Connection&lt;/h3&gt;  &lt;p&gt;The context menu in SSMS provides the ability to change a connection as well as connect and disconnect:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_72693005.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" width="546" height="115" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_11ABD6D9.png"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;SSDT doesn’t have change connection and believe me, you don’t know how much you use a feature until its not there:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_09B43477.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;display:inline;border-top-width:0px;" border="0" alt="image" width="438" height="58" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_28F6DB4A.png"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;There’s also no hotkey to jump to “Connection” on the context menu like there is in SSMS (“C”) and I find that annoying too.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;hr&gt;Those were the main annoyances that forced me back to SSMS. The lack of F6 was a major bugbear for me as I am a big keyboard shortcut junkie. If such things don’t bother you then you may be able to live in Visual Studio quite happily. If you have any similar experiences to share I’d be keen to read them.&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;a target="_blank" href="http://twitter.com/jamiet"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Deployment of client-specific database code using SSDT</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/03/10/deployment-of-client-specific-database-code-using-ssdt.aspx</link><pubDate>Sun, 10 Mar 2013 13:24:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:48159</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;Yesterday I attended &lt;a target="_blank" href="http://www.sqlsaturday.com/194/"&gt;SQL Saturday 194&lt;/a&gt; in Exeter for which many people deserve credit but especially the organisers &lt;a target="_blank" href="https://twitter.com/fatherjack"&gt;Jonathan Allen&lt;/a&gt; &amp;amp; &lt;a target="_blank" href="https://twitter.com/mrs_fatherjack"&gt;Annette Allen&lt;/a&gt; and the sponsors &lt;a target="_blank" href="http://www.fusionio.com/"&gt;Fusion-IO&lt;/a&gt;, &lt;a target="_blank" href="http://www.confio.com/"&gt;Confio Software&lt;/a&gt;, &lt;a target="_blank" href="http://www.nexusopensystems.co.uk/"&gt;Nexus&lt;/a&gt;, &lt;a target="_blank" href="http://www.bigbangdata.co.uk/Pages/default.aspx"&gt;Big Bang Data Company&lt;/a&gt;, &lt;a target="_blank" href="http://www.purplefrogsystems.com/"&gt;Purple Frog Systems&lt;/a&gt;, &lt;a target="_blank" href="http://www.red-gate.com/"&gt;Redgate&lt;/a&gt;, &lt;a target="_blank" href="http://www.idera.com/"&gt;idera&lt;/a&gt;, &lt;a target="_blank" href="http://pluralsight.com"&gt;Pluralsight&lt;/a&gt;, &lt;a target="_blank" href="http://exeterhotels.jurysinns.com/"&gt;Jurys Inn Exeter&lt;/a&gt; &amp;amp; &lt;a target="_blank" href="http://eu.wiley.com/"&gt;Wrox&lt;/a&gt;.&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2"&gt;     &lt;tr&gt;       &lt;td&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_072C63C9.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" width="327" height="238" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_312C61F1.png"&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_57221247.png"&gt;&lt;img title="image" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="image" width="317" height="296" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_161392E3.png"&gt;&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;hr&gt;I gave a talk entitled &lt;b&gt;Declarative Database Development with SSDT&lt;/b&gt;; both during the session and then afterwards on Twitter &lt;a target="_blank" href="https://twitter.com/leopasta"&gt;Leo Pasta&lt;/a&gt; asked me&lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a target="_blank" href="https://twitter.com/leopasta/status/310680898049826816"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" width="519" height="281" src="http://sqlblog.com/blogs/jamie_thomson/image_5505137E.png"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;&lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;&lt;a target="_blank" href="https://twitter.com/leopasta/status/310680898049826816"&gt;would you have any extra references on how to handle client-specific changes to the DB schema&lt;/a&gt;&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I promised Leo an answer, hence this blog post.&lt;/p&gt;  &lt;p&gt;If I understand Leo’s question correctly he has an application that is used by multiple clients, he has a separate instance of the application for every client, and the database requires client-specific customisations; luckily for Leo there is a new feature in SSDT that is perfect for this situation. First let’s set up our solution in SSDT:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_45EE34A4.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" width="359" height="284" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_52E814B5.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We have three database projects:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;_core - This contains all the objects that are common to all clients. For demonstration purposes it simply contains a table called [Sales]&lt;/li&gt;    &lt;li&gt;clientFoo – All the objects that are required only by client “Foo”. In this case there is view which aggregates the data in [Sales] by Customer&lt;/li&gt;    &lt;ul&gt;&lt;/ul&gt;    &lt;li&gt;clientBar – All the objects that are required only by client “Bar”. In this case there is view which aggregates the data in [Sales] by Location&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In order that the reference to table [Sales] in the two views can be resolved both of the client-specific projects have a database reference to _core:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_38A7AB91.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" width="242" height="244" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_09E1F2EF.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It is those database references that allows objects in clientFoo/clientBar to refer to objects in _core. Now here’s the important bit. When we set up those two database references &lt;b&gt;we must specify that the objects in the referenced project are intended to be in the same database&lt;/b&gt;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLa9aab43_48D3738A.png"&gt;&lt;img title="SNAGHTMLa9aab43" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLa9aab43" width="643" height="525" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLa9aab43_thumb_4722A7B6.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Having objects from one database split over multiple projects is called &lt;b&gt;composite projects&lt;/b&gt;. The effect of this is that (by default) whenever clientFoo or clientBar are deployed &lt;b&gt;the objects in _core will get deployed as well&lt;/b&gt;. We can see this in the output when we deploy clientFoo:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_5ACF914A.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" width="561" height="166" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_59F72B60.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Notice how &lt;b&gt;even though we chose not to deploy _core&lt;/b&gt; two objects have been created; table [Sales] (from the _core project) and view [vSalesPerCustomer]. This is the new feature in SSDT that I spoke of above – a deployment of a project will (by default) also deploy all the objects in referenced projects where objects in the referenced database are intended to be in the same database (incidentally this functionality replaces the “partial projects” feature from previous incarnations of SSDT).&lt;/p&gt;  &lt;p&gt;Note that you can change this default behaviour in the advanced publish settings by unchecking the “Include composite objects” box:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLaac90d1_5CBCE053.png"&gt;&lt;img title="SNAGHTMLaac90d1" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLaac90d1" width="422" height="612" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLaac90d1_thumb_61BF1E02.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Hence, with the “Include Composite Objects” setting turned on, we can deploy both projects clientFoo &amp;amp; clientBar and both will contain table [Sales] plus their own client-specific view:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_2E16B1A4.png"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" width="394" height="628" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_3F1ADF87.png"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;which (I hope) is exactly what Leo was after!&lt;/p&gt;  &lt;p&gt;That’s all there is to it. A very very nice new feature of SSDT!&lt;/p&gt;  &lt;p&gt;&lt;a target="_blank" href="http://twitter.com/jamiet"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Which version of SSDT Database Projects do I have installed?</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/02/08/which-version-of-ssdt-database-projects-do-i-have-installed.aspx</link><pubDate>Fri, 08 Feb 2013 21:15:52 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47608</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;SQL Server Data Tools (SSDT) is released on a very regular cadence (note that I’m talking about the &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/04/03/ssdt-what-s-in-a-name.aspx" target="_blank"&gt;database projects part of SSDT&lt;/a&gt;, this is nothing to do with SSIS/SSAS/SSRS). Since the first release in &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/03/05/available-today-sql-server-data-tools-rtw.aspx" target="_blank"&gt;March 2012&lt;/a&gt; there have been releases in &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/09/14/now-available-sql-server-data-tools-september-2012-update.aspx" target="_blank"&gt;September 2012&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/11/07/sql-server-data-tools-november-2012-is-now-available.aspx" target="_blank"&gt;November 2012&lt;/a&gt;, &amp;amp; &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/12/13/available-today-ssdt-december-2012.aspx" target="_blank"&gt;December 2012&lt;/a&gt;. I personally have found it difficult to keep track of not only which particular version I am using but also that which are my colleagues are using – quite simply I didn’t know how to discover the current version number. I assumed that the answer would lie within Visual Studio 2012 in the Help-&amp;gt;About Microsoft Visual Studio menu option, when I checked there I saw this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML339e96a2_1BDE30CA.png"&gt;&lt;img title="SNAGHTML339e96a2" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="SNAGHTML339e96a2" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML339e96a2_thumb_286BDDE6.png" width="507" height="333" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;A version number – 11.1.21208.0. What does that mean though? To understand more we have to go to Add/Remove programs:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML42d8efe8_2008088F.png"&gt;&lt;img title="SNAGHTML42d8efe8" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="SNAGHTML42d8efe8" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML42d8efe8_thumb_528B6601.png" width="934" height="275" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are many different items listed there, let’s look at them in turn:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Microsoft SQL Server 2012 Data-Tier App Framework&lt;/strong&gt;. This is fairly self-explanatory if you know what the Data-Tier App Framework (aka DACFx) is. If you don’t, see the notes at the end of this blog post*. The reason that you see two entries in the list above is due to my having the 32bit &amp;amp; 64bit versions installed – the fact that there is no differentiation between the two in the title is a bug. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server 2012 Express LocalDB&lt;/strong&gt;. LocalDB is the small server-less version of SQL Server that now gets deployed with SQL Server proper. LocalDB also gets installed with SSDT if you do not already have it, but you should consider it part of SQL Server itself. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools 2010&lt;/strong&gt;. This was described to me as the “installation chainer” – it is the installation component that manages SSDT and its dependencies. I think of it as the SSDT shell within Visual Studio 2010. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools 2012&lt;/strong&gt;. This was described to me as the “installation chainer” – it is the installation component that manages SSDT and its dependencies. I think of it as the SSDT shell within Visual Studio 2012. Note that the version number is the same as in the Help-&amp;gt;About screenshot at the top of this article – that is because they are one and the same. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools – Database Projects – Web installer entry point&lt;/strong&gt;. A stub project that gets installed when you install SQL Server. Its the SSDT database project entry point. &lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;u&gt;&lt;strong&gt;Microsoft SQL Server Data Tools – enu (10.3.21208.0)&lt;/strong&gt; &amp;amp; &lt;strong&gt;Microsoft SQL Server Data Tools – enu (11.1.21208.0)&lt;/strong&gt;. These are the things we’re interested in. These *are* SSDT database projects, for Visual Studio 2010 &amp;amp; Visual Studio 2012 respectively. The version numbers are those for the December 2012 release; note that the build numbers are the same (X.X.21208.X), only the major and minor numbers are different.&lt;/u&gt;&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Microsoft SQL Server Data Tools Build Utilities – enu (10.3.21208.0)&lt;/strong&gt; &amp;amp; &lt;strong&gt;Microsoft SQL Server Data Tools Build Utilities – enu (11.1.21208.0)&lt;/strong&gt;. Everything you need to do a headless (i.e. without having Visual Studio installed) build/deploy of an SSDT database project. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So at the end of all that we have determined the following version numbers for SSDT database projects are:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2"&gt;     &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;&lt;strong&gt;Release&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;&lt;strong&gt;Visual Studio 2010 version number&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;&lt;strong&gt;Visual Studio 2012 version number&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;September 2012&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;10.3.20905.0&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;11.1.20905.0&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;November 2012&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;10.3.21101.1&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;11.1.21101.1&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;         &lt;p align="center"&gt;December 2012&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;10.3.21208.0&lt;/p&gt;       &lt;/td&gt;        &lt;td&gt;&amp;nbsp;&lt;/td&gt;        &lt;td&gt;         &lt;p align="center"&gt;11.1.21208.0&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;strike&gt;I do not know the version numbers for the March 2012, September 2012 &amp;amp; November 2012 releases (if anyone out there does know please let me know in the comments) however I shall update this blog post for future releases.&lt;/strike&gt; September 2012 and November 2012 releases now added!&lt;/p&gt;  &lt;p&gt;I have requested that any blog post to announce future releases should contain the version numbers. Let’s hope that happens.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;* DACFx is described &lt;a href="http://www.microsoft.com/en-gb/download/details.aspx?id=35756" target="_blank"&gt;here&lt;/a&gt; as:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The Microsoft® SQL Server® 2012 Data-Tier Application Framework (DACFx) is a component which provides application lifecycle services for database development and management for Microsoft® SQL Server® and Windows Azure SQL Databases.      &lt;br /&gt;DacFX supports various database deployment and management scenarios for SQL Server and Windows Azure SQL Databases including extracting/exporting a live database to a DAC package, deploying a DAC package to a new or existing database, and migrating from on-premise SQL Server to Windows Azure. This functionality is exposed via the DACFx managed API. DACFx can target SQL Server 2005 SP4, 2008 SP1, 2008R2, 2012, and Windows Azure SQL Databases. DACFx also provides the command-line utility SqlPackage.exe for creating and deploying .dacpac and .bacpac packages. DACFx supports scenarios provided by SQL Server client tooling including SQL Server Data Tools and SQL Server Management Studio 2012.&lt;/p&gt;&lt;/blockquote&gt;</description></item><item><title>Responses to SSDT questions</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/01/11/responses-to-ssdt-questions.aspx</link><pubDate>Fri, 11 Jan 2013 22:22:24 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47124</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;My recent article &lt;a href="http://www.devproconnections.com/article/sql-server-2012/sql-server-2012-data-tools-144829"&gt;Get to Know SQL Server 2012's SQL Server Data Tools&lt;/a&gt; prompted two questions to come to me via email and in the interests of sharing knowledge via search engines I thought I would answer them here rather than by simply replying by email (I hate that so much useful information gets trapped inside closed inboxes).&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Question: How would you handle cases below, our main database has many objects already, we are using redgate source control to keep things under sourcecontrol but ssdt would be awesome.        &lt;br /&gt;Our database has some invalid stored procs etc, unfortunately we do not want to drop them, underlying objects either don't exists or has changed etc         &lt;br /&gt;There are linked servers or code referencing other objects stored in the database         &lt;br /&gt;There are staging table named automatically in the database and we do not want to include them in the project and not drop them or touch them in a deploy &lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;JT: The overall question here seems to be “how do we prevent SSDT from DROPping sprocs and staging tables that are in the target database but are not in the SSDT project?” Fortunately SSDT has an option within it to allow exactly what the questioner requires. When an SSDT project is published one has the option to set some properties relating to that publish. One of the settings is “DROP objects in target but not in project”:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML5751f10_20688721.png"&gt;&lt;img title="SNAGHTML5751f10" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" border="0" alt="SNAGHTML5751f10" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML5751f10_thumb_11A9A170.png" width="340" height="484" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;If that option is left unchecked (which is the default) then no objects will get removed from the target database.&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Question: At my previous shop, I done a proof of concept with one of our databases, but never got it implemented as VS2012 (with SSDT) had not been released yet. Well, fast forward 9 or so months, and at my new shop (which is extremely agile) I've been tasked with setting up our db projects with SSDT so for the immediate short term goals/objectives we can;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Allow new or existing developers to be able to easily get the latest databases from source control downloaded from TFS, built and deployed onto our local sandbox db environments. This ideally will be done via a powershell script or something of the sort. &lt;/font&gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;font color="#c0504d"&gt;&lt;em&gt;Be able to employ C.I. so that every night a database deployment is done to our system test servers.&lt;/em&gt; &lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;3 days into it, and I've wrestled with 3 of our databases, reverse engineering them into TFS and getting them built etc. My question is, what are the best practices or guidelines for;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Allowing only Windows authentication for the local deploys to the sandbox environment. i.e. is it best to have a script with all our team user logins in a script? How would the project recognise a team member which will create a login for them so once the project is deployed they can login to their local db? &lt;/font&gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Using a 1-touch/click action (preferably outside of VS2010) to get latest, build project &amp;amp; deploy to local sandbox &lt;/font&gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;font color="#c0504d"&gt;Same as above but to a system test server&lt;/font&gt;&lt;/em&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;JT: There are quite a few questions there. Firstly I’ll say that its great to hear of sandboxed environments and Continuous Integration (CI) being used – I openly advocate these techniques in my blog post &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/01/01/implementing-sql-server-solutions-using-visual-studio-2010-database-projects-a-compendium-of-project-experiences.aspx"&gt;Implementing SQL Server solutions using Visual Studio 2010 Database Projects – a compendium of project experiences&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Now, taking each question in turn:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Windows Auth for local deploys. I’m not sure if there’s any recognised best practise here but if developers are working on local sandboxes I would assume they would have sysadmin rights so I’m not sure there’s a need to have a script of team logins. Perhaps I have misunderstood the question in which case please clarify in the comments below. I will say this though – I think its better to have a Windows group that you can move all of your devs in and out of rather than having to modify a script each time a user joins your team. &lt;/li&gt;    &lt;li&gt;1-click get latest, build &amp;amp; deploy. Scripting your build &amp;amp; deploy is something else I advocate in the &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/01/01/implementing-sql-server-solutions-using-visual-studio-2010-database-projects-a-compendium-of-project-experiences.aspx"&gt;aforementioned blog post&lt;/a&gt;:       &lt;blockquote&gt;       &lt;p&gt;&lt;em&gt;Building and deploying your datadude projects within Visual Studio can become a real time hog; in my experience its not unusual for deployments to take many minutes and your Visual Studio environment will be unavailable for further development work during that time. For that reason I recommend investing some time in writing some msbuild scripts that will build and deploy your project(s) from the command-line.&lt;/em&gt;&lt;/p&gt;     &lt;/blockquote&gt;      &lt;p&gt;I’ll go further here and say that the script with which you use to build and deploy to your sandbox should be the same script as which you use for your production environment and everything in between. The script should take a parameter value to name the environment and then deploy appropriately.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;See 2. &lt;/li&gt; &lt;/ol&gt;    &lt;hr /&gt;Hope that is useful. Any questions? Please put them in the comments.    &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Get to Know SQL Server 2012's SQL Server Data Tools [article published]</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/01/09/get-to-know-sql-server-2012-s-sql-server-data-tools-article-published.aspx</link><pubDate>Wed, 09 Jan 2013 23:12:03 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47093</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;I recently wrote an article on SQL Server Data Tools for SQL Server Magazine and it has now been published online at &lt;a href="http://www.devproconnections.com/article/sql-server-2012/sql-server-2012-data-tools-144829" target="_blank"&gt;Get to Know SQL Server 2012's SQL Server Data Tools&lt;/a&gt;. In the article I offer my thoughts and opinions on SQL Server Data Tools as it exists in SQL Server 2012.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://www.devproconnections.com/article/sql-server-2012/sql-server-2012-data-tools-144829"&gt;&lt;img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_54C3565A.png" width="558" height="231" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Note that the article refers to SSDT database projects only, there is nothing in there pertaining to SSIS, SSAS or SSRS. If you find that confusing then you should probably go and at least read the first few paragraphs of the article where I try to alleviate some of that confusion.&lt;/p&gt;  &lt;p&gt;Constructive feedback is, as always, very welcome.&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>“Add as object” or “Add as script”? [SSDT]</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/01/04/add-as-object-or-add-as-script-ssdt.aspx</link><pubDate>Fri, 04 Jan 2013 14:15:46 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47006</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;In SQL Server Data Tools (SSDT) one way to create a new object is to right click on a folder in Solution Explorer and point to Add. Doing so will display this menu:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_20905F62.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_0215F8AC.png" width="505" height="203" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;A number of options are offered for creating a brand new object (“function”, “table”, “stored proc” etc…) and one of them is “Script”. If your preference is to handcraft the DDL for every database object without resorting to a GUI then you may choose to use the “Script” option because, after all, every file is just a DDL script – why not write the thing from scratch? There is however one fundamental difference between the Script” option and all the other options that you should be aware of.&lt;/p&gt;  &lt;p&gt;For the screenshot below I added a script and handcrafted a simple CREATE TABLE statement:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML760417d0_6BDFDD59.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="SNAGHTML760417d0" border="0" alt="SNAGHTML760417d0" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTML760417d0_thumb_6D44002B.png" width="778" height="359" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Notice that the table is defined in the dbo schema but it is not appearing in SQL Server Object Explorer under the dbo schema node. Why is that? The answer is actually pretty simple. If I select Script1.sql in Solution Explorer and hit F4 the properties window appears and we see this:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_3686A527.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7C97623A.png" width="304" height="276" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The Build Action property of the file is set to “None” which means that the file does not get included in a build and hence any objects defined within that file will not appear in our database. This is the default behaviour when you Add as script whereas the default behaviour when you explicitly add an object is to set Build Action=Build. That is the fundamental difference between adding a script and adding a specific object.&lt;/p&gt;  &lt;p&gt;This is one of those nuances of SSDT that is an easy problem to spot when you know about it but can cause you to spend hours hunting around for a solution if you do not (believe me, I’ve been there). Be aware of it!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Warning! Publish may fail on creation of a FOREIGN KEY constraint and then immediately succeed [SSDT]</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2013/01/03/warning-publish-may-fail-on-creation-of-a-foreign-key-constraint-and-then-immediately-succeed-ssdt.aspx</link><pubDate>Thu, 03 Jan 2013 12:15:06 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:46978</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;I have stumbled across a nuance of SSDT that other users should be cognizant of. I published an SSDT database project onto an existing database that already had data in it but that Publish operation failed:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_71C1CD88.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_02C5FB6C.png" width="492" height="135" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The error message was:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font color="#ff0000"&gt;(10036,1): SQL72014: .Net SqlClient Data Provider: Msg 547, Level 16, State 0, Line 1 &lt;br /&gt;The ALTER TABLE statement conflicted with the FOREIGN KEY constraint &lt;br /&gt;&amp;quot;ActualsDay_fct_ent_CustomerHierarchyLvl03_FK_PayTo&amp;quot;. &lt;br /&gt;The conflict occurred in database &amp;quot;PM_EDW&amp;quot;, table &amp;quot;ent.CustomerHierarchyLvl03&amp;quot;, column &lt;br /&gt;'CstHierLvl03_EK'.&lt;/font&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;The command that caused the error was:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre style="text-align:left;list-style-type:disc;font-family:;background:white;color:;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:9.8pt;"&gt;ALTER&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9.8pt;"&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;TABLE&lt;/font&gt;&lt;/span&gt; [fct]&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;[ActualsDay] &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;WITH&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;CHECK&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;CHECK&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;CONSTRAINT&lt;/font&gt;&lt;/span&gt; [ActualsDay_fct_ent_CustomerHierarchyLvl03_FK_PayTo]&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;;&lt;/font&gt;&lt;/span&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words SSDT created a FOREIGN KEY constraint in my database and then attempted to check that existing data satisfied that constraint (hence the &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;WITH&lt;/font&gt;&lt;/span&gt; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;CHECK&lt;/font&gt;&lt;/span&gt; of the command above). There was some data that violated that constraint and the Publish operation failed.

  &lt;br /&gt;This is good, I definitely want a Publish operation to fail under these circumstances.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;If you want to understand more about &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;WITH&lt;/font&gt;&lt;/span&gt; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;CHECK&lt;/font&gt;&lt;/span&gt; take a read of &lt;/em&gt;&lt;a href="http://consultingblogs.emc.com/jamiethomson/archive/2006/02/17/SSIS_3A00_-How-to-load-related-tables.aspx" target="_blank"&gt;&lt;em&gt;How to load related tables&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A problem occurred though when I next published because that Publish operation actually succeeded:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_41B77C07.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_07C8391B.png" width="490" height="134" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;even though &lt;strong&gt;I hadn’t changed anything in the project&lt;/strong&gt;! If I check out the metadata of that FOREIGN KEY:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre style="text-align:left;list-style-type:disc;font-family:;background:white;color:;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:9.8pt;"&gt;SELECT&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9.8pt;"&gt;	name&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;is_not_trusted
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;FROM&lt;/font&gt;&lt;/span&gt;	&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;sys&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;.&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;foreign_keys&lt;/font&gt;&lt;/span&gt;&amp;#160; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;WHERE&lt;/font&gt;&lt;/span&gt;	name &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#ff0000"&gt;'ActualsDay_fct_ent_CustomerHierarchyLvl03_FK_PayTo'&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;I see that [is_not_trusted] equals 1.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_18CC66FE.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_30EFD159.png" width="469" height="192" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What does that mean, exactly? Well, SSMS’s table designer provides more useful information:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_16AF6835.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4E81AC58.png" width="548" height="346" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;[is_not_trusted] means that my new FOREIGN KEY constraint has been created but the existing data has not been checked for compliance. Ouch! Not good, not good at all!&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;What’s going on here? If we break down the individual steps it becomes evident:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;First Publish operation starts&lt;/li&gt;

  &lt;li&gt;FOREIGN KEY constraint gets created but without the WITH CHECK option&lt;/li&gt;

  &lt;li&gt;FOREIGN KEY constraint is ALTERed to have the WITH CHECK option. This fails due to existing data violating the constraint and hence the entire Publish operation fails&lt;/li&gt;

  &lt;li&gt;Second Publish operation starts&lt;/li&gt;

  &lt;li&gt;Publish engine only checks to see that the FOREIGN KEY constraint exists, which it does. Hence, no action is taken&lt;/li&gt;

  &lt;li&gt;Second Publish operation succeeds and I’m left with data that violates a newly created FOREIGN KEY constraint&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This sequence of events can leave your database in a dangerous state and hence is something that SSDT users should be aware of. In my opinion this is a bug and I have raised it as such on Microsoft Connect: &lt;a href="https://connect.microsoft.com/SQLServer/feedback/details/775683/ssdt-bug-publish-will-fail-due-to-fk-constraint-and-then-succeed-immediately-after" target="_blank"&gt;[SSDT bug] Publish will fail due to FK constraint and then succeed immediately after&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Be aware, be very aware!&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>New version of SQL Server Data Tools is now available</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2012/09/16/new-version-of-sql-server-data-tools-is-now-available.aspx</link><pubDate>Sun, 16 Sep 2012 22:03:45 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:45224</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;If you don’t follow the &lt;a href="http://blogs.msdn.com/b/ssdt/" target="_blank"&gt;SQL Server Data Tools (SSDT) blog&lt;/a&gt; then you may not know that two days ago an updated version of SSDT was released (&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/04/03/ssdt-what-s-in-a-name.aspx" target="_blank"&gt;and by SSDT I mean the database projects, not the SSIS/SSRS/SSAS stuff&lt;/a&gt;) along with a new version of the SSDT Power Tools. This release incorporates a an updated version of the SQL Server Data Tier Application Framework (aka DAC Framework, aka DacFX) which you can read about on Adam Mahood’s blog post &lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/09/11/sql-server-data-tier-application-framework-september-2012-available.aspx" target="_blank"&gt;SQL Server Data-Tier Application Framework (September 2012) Available&lt;/a&gt;. DacFX is essentially all the gubbins that you need to extract and publish .dacpacs and according to Adam’s post it incorporates a new feature that I think is very interesting indeed:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;Extract DACPAC with data – Creates a database snapshot file (.dacpac) from a live SQL Server or Windows Azure SQL Database that contains data from user tables in addition to the database schema. These packages can be published to a new or existing SQL Server or Windows Azure SQL Database using the SqlPackage.exe Publish action. Data contained in package replaces the existing data in the target database.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In short, .dacpacs can now include data as well as schema. I’m very excited about this because one of my long-standing complaints about SSDT (and its many forebears) is that whilst it has great support for declarative development of schema it does not provide anything similar for data – if you want to deploy data from your SSDT projects then you have to write Post-Deployment MERGE scripts. This new feature for .dacpacs does not change that situation yet however it is a very important pre-requisite so I am hoping that a feature to provide declaration of data (in addition to declaration of schema which we have today) is going to light up in SSDT in the not too distant future.&lt;/p&gt;  &lt;p&gt;Read more about the latest SSDT, Power Tools &amp;amp; DacFX releases at:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/09/14/now-available-sql-server-data-tools-september-2012-update.aspx" target="_blank"&gt;Now available: SQL Server Data Tools - September 2012 update!&lt;/a&gt; by &lt;a href="http://social.msdn.microsoft.com/profile/janet%20yeilding/" target="_blank"&gt;Janet Yeilding&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/09/14/new-ssdt-power-tools-now-for-both-visual-studio-2010-and-visual-studio-2012.aspx" target="_blank"&gt;New SSDT Power Tools! Now for both Visual Studio 2010 and Visual Studio 2012&lt;/a&gt; by &lt;a href="http://social.msdn.microsoft.com/profile/sarahmcd/" target="_blank"&gt;Sarah McDevitt&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/ssdt/archive/2012/09/11/sql-server-data-tier-application-framework-september-2012-available.aspx" target="_blank"&gt;SQL Server Data-Tier Application Framework (September 2012) Available&lt;/a&gt; by &lt;a href="http://social.msdn.microsoft.com/profile/adam%20mahood%20%5Bmsft%5D/" target="_blank"&gt;Adam Mahood&lt;/a&gt;&lt;/li&gt; &lt;/ul&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>CASTs become CONVERTs in computed columns with implications for SSDT</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2012/07/19/casts-become-converts-in-computed-columns-with-implications-for-ssdt.aspx</link><pubDate>Thu, 19 Jul 2012 10:03:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44367</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;I discovered a peculiar little nuance in SQL Server yesterday that I think is worth sharing. Execute the following CREATE TABLE statement:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre style="background:white;text-align:left;font-family:;list-style-type:disc;"&gt;&lt;font face="Consolas"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size:9.8pt;"&gt;CREATE&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9.8pt;"&gt;&amp;nbsp;&lt;span&gt;&lt;font color="#0000ff"&gt;TABLE&lt;/font&gt;&lt;/span&gt; _t&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;c &lt;span&gt;&lt;font color="#0000ff"&gt;INT&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;
	[S_Profit] &lt;span&gt;&lt;font color="#0000ff"&gt;AS &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff00ff"&gt;CAST&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;1 &lt;span&gt;&lt;font color="#0000ff"&gt;AS&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span&gt;&lt;font color="#0000ff"&gt;DECIMAL &lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;19&lt;span&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt; 6&lt;span&gt;&lt;font color="#808080"&gt;)))&lt;/font&gt;&lt;/span&gt;
&lt;/font&gt;&lt;span&gt;&lt;font style="font-size:9.8pt;" color="#808080"&gt;);&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you then go to Object Explorer and script that table out:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_1FC6954A.png"&gt;&lt;img style="border:0px currentColor;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_7120669A.png" width="535" height="148"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;you see this:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_21D36E46.png"&gt;&lt;img style="border:0px currentColor;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_47C91E9C.png" width="458" height="199"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Notice how the definition of the [S_Profit] computed column is not the same as it was what we created the table, it is now a CONVERT rather than a CAST.&lt;/p&gt;



&lt;p&gt;OK, so that behaviour might be considered a little strange but its hard to see why it might be a problem. Well, it actually &lt;i&gt;did&lt;/i&gt; create a problem for me yesterday as I shall now explain. &lt;/p&gt;



&lt;p&gt;On my current project we are using &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 in SQL Server Data Tools&lt;/a&gt; (SSDT) [&lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2012/04/03/ssdt-what-s-in-a-name.aspx" target="_blank"&gt;and by “SSDT” I mean the database projects, not the Visual Studio shell around the SSIS/SSAS/SSRS stuff&lt;/a&gt;] to deploy our database schema. That schema included computed columns using CAST and hence every time we attempted a publish SSDT would compare the table definition in the project with the existing table in the target and notice that they were different. This can be better better illustrated using SSDT’s Schema Compare tool (which does essentially the same comparison as is done at publish time):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_1177F68D.png"&gt;&lt;img style="border:0px currentColor;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_4B86C36C.png" width="840" height="182"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Notice where I have &lt;u&gt;&lt;font color="#c0504d"&gt;underlined in red&lt;/font&gt;&lt;/u&gt; that the table definition in my source uses a CAST yet in the target it was changed to a CONVERT the last time we published. Notice also, &lt;u&gt;&lt;font color="#008000"&gt;underlined in green&lt;/font&gt;&lt;/u&gt;, that another expression has been rewritten to take out parentheses. Here’s a similar case where DEFAULT constraints also get rewritten:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_34E47525.png"&gt;&lt;img style="border:0px currentColor;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_4C9BAC8B.png" width="854" height="54"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Another one, keywords in CHECK constraints get uncapitalised* and parentheses get added in:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_79446664.png"&gt;&lt;img style="border:0px currentColor;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_57E4C0C8.png" width="851" height="46"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At publish time SSDT will generate a script that will attempt to make the target look like the source hence it is going to be making the same changes to these computed columns, default constraints and check constraints &lt;i&gt;every single time you publish&lt;/i&gt;. Also note that any dependent objects will get affected too; e.g. dependent views may get dropped and recreated – if those views have indexes on them and there is a lot of data in those indexes then your publish operations are going to take a longggggg time.&lt;/p&gt;

&lt;p&gt;The point is, your SSDT publishes might be working fine yet doing a lot more work than they actually need to so I would encourage you to change the default constraints, check constraints and computed column definitions in your source code to whatever SQL Server rewrites it to. The Schema Compare tool is your friend when trying to do this.&lt;/p&gt;&lt;p&gt;UPDATE: There was a little confusion from &lt;a href="https://twitter.com/DBA_ANDY/status/225947185198538752" target="_blank"&gt;someone on Twitter&lt;/a&gt;&amp;nbsp;as to where the problem lies here. Its is not something that SSDT is doing incorrectly, the re-writing is being done by the database engine.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;*Is “uncapitalised” a word? What is the opposite of “capitalised”?&lt;/i&gt;&lt;/p&gt;</description></item><item><title>Bitmask data insertions in SSDT Post-Deployment scripts</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2012/06/11/bitmask-data-insertions-in-ssdt-post-deployment-scripts.aspx</link><pubDate>Mon, 11 Jun 2012 10:11:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:43825</guid><dc:creator>jamiet</dc:creator><description>&lt;p&gt;On my current project we are using SQL Server Data Tools (SSDT) to manage our database schema and one of the tasks we need to do often is insert data into that schema once deployed; the typical method employed to do this is to leverage Post-Deployment scripts and that is exactly what we are doing.&lt;/p&gt;  &lt;p&gt;Our requirement is a little different though, our data is split up into various buckets that we need to selectively deploy on a case-by-case basis. I was going to use a SQLCMD variable for each bucket (defaulted to some value other than “Yes”) to define whether it should be deployed or not so we could use something like this in our Post-Deployment script:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre style="font-size:12px;"&gt;&lt;font color="blue"&gt;IF &lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;$&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;DeployBucket1Flag&lt;/font&gt;&lt;font color="gray"&gt;) &lt;/font&gt;&lt;font color="blue"&gt;= &lt;/font&gt;&lt;font color="red"&gt;'Yes'&lt;/font&gt;&lt;font color="gray"&gt;)&lt;br /&gt;&lt;/font&gt;&lt;font color="blue"&gt;BEGIN&lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160; :r .\Bucket1.data.sql&lt;/font&gt;&lt;font color="black"&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="blue"&gt;END&lt;/font&gt;&lt;br /&gt;&lt;font color="blue"&gt;IF &lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;$&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;DeployBucket2Flag&lt;/font&gt;&lt;font color="gray"&gt;) &lt;/font&gt;&lt;font color="blue"&gt;= &lt;/font&gt;&lt;font color="red"&gt;'Yes'&lt;/font&gt;&lt;font color="gray"&gt;)&lt;br /&gt;&lt;/font&gt;&lt;font color="blue"&gt;BEGIN&lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160; :r .\Bucket2.data.sql&lt;/font&gt;&lt;font color="black"&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="blue"&gt;END&lt;/font&gt;&lt;br /&gt;&lt;font color="blue"&gt;IF &lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="black"&gt;$&lt;/font&gt;&lt;font color="gray"&gt;(&lt;/font&gt;&lt;font color="#000000"&gt;DeployBucket3Flag&lt;/font&gt;&lt;font color="gray"&gt;) &lt;/font&gt;&lt;font color="blue"&gt;= &lt;/font&gt;&lt;font color="red"&gt;'Yes'&lt;/font&gt;&lt;font color="gray"&gt;)&lt;br /&gt;&lt;/font&gt;&lt;font color="blue"&gt;BEGIN&lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160; :r .\Bucket3.data.sql&lt;/font&gt;&lt;font color="black"&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="blue"&gt;END&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;That works fine and is, I’m sure, a very common technique for doing this. It is however slightly ugly because we have to litter our deployment with various SQLCMD variables. My colleague James Rowland-Jones (&lt;a href="http://www.sqlpass.org/AboutPASS/JamesRowlandJones.aspx" target="_blank"&gt;whom I’m sure&lt;/a&gt; &lt;a href="http://sqlbits.com/(X(1)S(rvhw4svwhvv403unuasmdl45))/about/WhosWho.aspx" target="_blank"&gt;many of you know&lt;/a&gt;) suggested another technique – bitmasks. I won’t go into detail about how this works (James has already done that at &lt;a href="http://consultingblogs.emc.com/jamesrowlandjones/archive/2008/07/04/using-a-bitmask-a-practical-example.aspx" target="_blank"&gt;Using a Bitmask - a practical example&lt;/a&gt;) but I’ll summarise by saying that you can deploy different combinations of the buckets simply by supplying a different numerical value for a single SQLCMD variable. Each bit of that value’s binary representation signifies whether a particular bucket should be deployed or not. This is better demonstrated using the following simple script (which can be easily leveraged inside your Post-Deployment scripts):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre style="text-align:left;list-style-type:disc;font-family:;background:white;color:;"&gt;&lt;font face="Consolas"&gt;&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;&lt;font style="font-size:9.8pt;"&gt;/* $(DeployData) is a SQLCMD variable that would, if you were using this in SSDT, be declared in the SQLCMD variables section of your &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9.8pt;"&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;project file. It should contain a numerical value, defaulted to 0.&lt;/font&gt;&lt;/span&gt;
 
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;In this example I have declared it using a :setvar statement. Test the affect of different values&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;by changing the :setvar statement accordingly.&lt;/font&gt;&lt;/span&gt;
 
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;Examples:&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;:setvar DeployData 1   &lt;span style="color:;"&gt;&lt;font color="#008000"&gt;will deploy bucket 1&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;:setvar DeployData 2   &lt;span style="color:;"&gt;&lt;font color="#008000"&gt;will deploy bucket 2&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;:setvar DeployData 3&amp;#160;&amp;#160; will deploy buckets 1 &amp;amp; 2&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;:setvar DeployData 6&amp;#160;&amp;#160; will deploy buckets 2 &amp;amp; 3&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;:setvar DeployData 31&amp;#160; will deploy buckets 1, 2, 3, 4 &amp;amp; 5&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#008000"&gt;*/&lt;/font&gt;&lt;/span&gt;
&lt;font style="background-color:#cccccc;"&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;:&lt;/font&gt;&lt;/span&gt;setvar DeployData 0&lt;/font&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;DECLARE&lt;/font&gt;&lt;/span&gt;&amp;#160; @bitmask &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;VARBINARY&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#ff00ff"&gt;MAX&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#ff00ff"&gt;CONVERT&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;VARBINARY&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;,&lt;/font&gt;&lt;/span&gt;$&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;DeployData&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;));&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;IF &lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;@bitmask &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;&amp;amp;&lt;/font&gt;&lt;/span&gt; 1 &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 1&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;PRINT&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#ff0000"&gt;'Bucket 1 insertions'&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;IF &lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;@bitmask &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;&amp;amp;&lt;/font&gt;&lt;/span&gt; 2 &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 2&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;PRINT&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#ff0000"&gt;'Bucket 2 insertions'&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;IF &lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;@bitmask &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;&amp;amp;&lt;/font&gt;&lt;/span&gt; 4 &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 4&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;PRINT&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#ff0000"&gt;'Bucket 3 insertions'&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;IF &lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;@bitmask &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;&amp;amp;&lt;/font&gt;&lt;/span&gt; 8 &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 8&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;PRINT&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#ff0000"&gt;'Bucket 4 insertions'&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;IF &lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;(&lt;/font&gt;&lt;/span&gt;@bitmask &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;&amp;amp;&lt;/font&gt;&lt;/span&gt; 16 &lt;span style="color:;"&gt;&lt;font color="#808080"&gt;=&lt;/font&gt;&lt;/span&gt; 16&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;)&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;BEGIN&lt;/font&gt;&lt;/span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;PRINT&lt;/font&gt;&lt;/span&gt;&amp;#160;&lt;span style="color:;"&gt;&lt;font color="#ff0000"&gt;'Bucket 5 insertions'&lt;/font&gt;&lt;/span&gt;&lt;span style="color:;"&gt;&lt;font color="#808080"&gt;;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color:;"&gt;&lt;font color="#0000ff"&gt;END&lt;/font&gt;&lt;/span&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;An example of running this using DeployData=6&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/image_635C9FBF.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7D505FE1.png" width="667" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The binary representation of 6 is 110. The second and third significant bits of that binary number are set to 1 and hence buckets 2 and 3 are “activated”.&lt;/p&gt;

&lt;p&gt;Hope that makes sense and is useful to some of you!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/jamiet" target="_blank"&gt;@Jamiet&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;P.S. I used the awesome &lt;a href="http://blogs.msdn.com/b/kirillosenkov/archive/2010/06/07/copy-code-in-html-format-with-visual-studio-2010.aspx" target="_blank"&gt;HTML Copy&lt;/a&gt; feature of Visual Studio’s &lt;a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/" target="_blank"&gt;Productivity Power Tools&lt;/a&gt; in order to format the T-SQL code above for this blog post.&lt;/p&gt;</description></item></channel></rss>