<?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 'Visual Studio' and 'Datadude'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Visual+Studio,Datadude&amp;orTags=0</link><description>Search results matching tags 'Visual Studio' and 'Datadude'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Querying Visual Studio project files using T-SQL and Powershell</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2011/01/17/querying-visual-studio-project-files.aspx</link><pubDate>Mon, 17 Jan 2011 21:11:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:32686</guid><dc:creator>jamiet</dc:creator><description>&lt;P&gt;Earlier today I had a need to get some information out of a Visual Studio project file and in this blog post I’m going to share a couple of ways of going about that because I’m pretty sure I won’t be the only person that ever wants to do this. The specific problem I was trying to solve was finding out how many objects in my database project (i.e. in my .dbproj file) had any warnings suppressed but the techniques discussed below will work pretty well for any Visual Studio project file because every such file is simply an XML document, hence it can be queried by anything that can query XML documents.&lt;/P&gt;
&lt;P&gt;Ever heard the phrase “when all you’ve got is hammer everything looks like a nail”? Well that’s me with querying stuff – if I can write SQL then I’m writing SQL. Here’s a little noddy database project I put together for demo purposes:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/image_003D882B.png"&gt;&lt;IMG style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title=image border=0 alt=image src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7E208961.png" width=211 height=244&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Two views and a stored procedure, nothing fancy. I suppressed warnings for [View1] &amp;amp; [Procedure1] and hence the pertinent part my project file looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;ItemGroup&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;nbsp;&lt;FONT color=#ff0000&gt;Include&lt;/FONT&gt;=&lt;FONT color=#000000&gt;"&lt;/FONT&gt;Schema Objects\Schemas\dbo\Views\View1.view.sql&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;Code&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT size=3&gt;&amp;lt;&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;4151,3276&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;Include&lt;/FONT&gt;=&lt;FONT color=#000000&gt;"&lt;/FONT&gt;Schema Objects\Schemas\dbo\Views\View2.view.sql&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;Code&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;Include&lt;/FONT&gt;=&lt;FONT color=#000000&gt;"&lt;/FONT&gt;Schema Objects\Schemas\dbo\Programmability\Stored Procedures\Procedure1.proc.sql&lt;FONT color=#000000&gt;"&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;Code&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SubType&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT size=3&gt;&amp;lt;&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;FONT color=#000000&gt;4151&lt;/FONT&gt;&amp;lt;/&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;Build&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/&lt;FONT color=#c0504d&gt;ItemGroup&lt;/FONT&gt;&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;&lt;FONT color=#c0504d&gt;ItemGroup&lt;/FONT&gt;&amp;gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Note the &lt;STRONG&gt;&amp;lt;&lt;FONT color=#c0504d&gt;SuppressWarnings&lt;/FONT&gt;&amp;gt; &lt;/STRONG&gt;elements – those are the bits of information that I am after.&lt;/P&gt;
&lt;P&gt;With &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/sqlxml/thread/2337b9bf-e123-4004-8af3-06d2b851c7e1/" target=_blank&gt;a lot of help&lt;/A&gt; from folks on the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/sqlxml/threads" target=_blank&gt;SQL Server XML forum&lt;/A&gt;&amp;nbsp; I came up with the following query that nailed what I was after. It reads the contents of the .dbproj file into a variable of type XML and then shreds it using T-SQL’s &lt;A href="http://msdn.microsoft.com/en-us/library/ms190798.aspx" target=_blank&gt;XML data type methods&lt;/A&gt;: &lt;/P&gt;
&lt;TABLE cellSpacing=0 cellPadding=2&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;CODE style="FONT-SIZE:12px;"&gt;&lt;SPAN style="COLOR:blue;"&gt;DECLARE &lt;/SPAN&gt;&lt;SPAN style="COLOR:#434343;"&gt;@xml &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;XML&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT &lt;/SPAN&gt;&lt;SPAN style="COLOR:#434343;"&gt;@xml &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;CAST&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;pkgblob.BulkColumn &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS XML&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;FROM&amp;nbsp;&amp;nbsp; OPENROWSET&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;BULK &lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'C:\temp\QueryingProjectFileDemo\QueryingProjectFileDemo.dbproj' &lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;-- &amp;lt;-Change this path! &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;single_blob&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;pkgblob &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;WITH &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;XMLNAMESPACES&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'http://schemas.microsoft.com/developer/msbuild/2003' &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;ns&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;REVERSE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;SUBSTRING&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;REVERSE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;ObjectPath&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;CHARINDEX&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'\'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:magenta;"&gt;REVERSE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;ObjectPath&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;)))) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[ObjectName] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[SuppressedWarnings] &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;FROM&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;( &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build.query&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'.'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[_node] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build.value&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'ns:SuppressWarnings[1]'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'nvarchar(100)'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[SuppressedWarnings] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build.value&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'@Include'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'nvarchar(1000)'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;[ObjectPath] &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;FROM&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#434343;"&gt;@xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;.nodes&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'//ns:Build[ns:SuppressWarnings]'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;AS &lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;R&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;build&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;SPAN style="COLOR:black;"&gt;q &lt;BR&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;And here’s the output:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/image_4E826AD5.png"&gt;&lt;IMG style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title=image border=0 alt=image src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_7B9757A3.png" width=533 height=164&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And that’s it – an easy way of discovering which warnings have been suppressed and for which objects in your database projects. I won’t bother going over the code as it is fairly self-explanatory – peruse it at your leisure.&lt;/P&gt;
&lt;P&gt;Once I had the SQL above I figured I’d share it around a little in case it was ever useful to anyone else; hence I’m writing this blog post and I also posted it on the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vstsdb/threads" target=_blank&gt;Visual Studio Database Development Tools forum&lt;/A&gt; at &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/8eacbe76-c6d1-40e2-af15-044903a98c1d/?prof=required" target=_blank&gt;FYI: Discover which objects have had warnings suppressed&lt;/A&gt;. Luckily &lt;A href="http://social.msdn.microsoft.com/profile/kevin%20goode/?type=forum&amp;amp;referrer=http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/8eacbe76-c6d1-40e2-af15-044903a98c1d/?prof=required" target=_blank&gt;Kevin Goode&lt;/A&gt; saw the thread and he posted a different solution to the same problem, one that uses Powershell. The advantage of Kevin’s Powershell approach is that it is easy to analyse many .dbproj files at the same time. Below is Kevin’s code which I have tweaked &lt;EM&gt;ever so slightly&lt;/EM&gt; so that it produces the same results as my SQL script (I just want any object that had had a warning suppressed whereas Kevin was querying specifically for warning 4151):&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;cd&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;C:\Temp\QueryingProjectFileDemo\&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;cls&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$projects&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;ls&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-r&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-i&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; *.dbproj
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;Foreach&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$project&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#0000ff;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$projects&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;)
{
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;new-object&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;System.Xml.XmlDocument&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:#8b4513;"&gt;set_PreserveWhiteSpace&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$true&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; )
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:#8b4513;"&gt;Load&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$project&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;)

  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;#&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;$xpath = @{Start="/e:Project/e:ItemGroup/e:Build[e:SuppressWarnings=4151]/@Include"}&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;#&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;$xpath = @{Start="/e:Project/e:ItemGroup/e:Build[contains(e:SuppressWarnings,'4151')]/@Include"}&lt;/SPAN&gt;&lt;SPAN style="COLOR:#008000;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xpath&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; @{Start&lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;/e:Project/e:ItemGroup/e:Build[e:SuppressWarnings]/@Include&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;}
  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$ns&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; @{ e &lt;/SPAN&gt;&lt;SPAN style="COLOR:#ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; }

  &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; | &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;Select-Xml&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-XPath&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$xpath&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;.Start  &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-Namespace&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800080;"&gt;$ns&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; |&lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-Expand&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;Node&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; | &lt;/SPAN&gt;&lt;SPAN style="COLOR:#5f9ea0;FONT-WEIGHT:bold;"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-STYLE:italic;COLOR:#5f9ea0;"&gt;-expand&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:#800000;"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="COLOR:#000000;"&gt;
}

&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;and here’s the output:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="http://sqlblog.com/blogs/jamie_thomson/image_60EABB8A.png"&gt;&lt;IMG style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;MARGIN:;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title=image border=0 alt=image src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4716855B.png" width=765 height=102&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Nice reusable Powershell and SQL scripts – not bad for an evening’s work. Thank you to Kevin for allowing me to share his code.&lt;/P&gt;
&lt;P&gt;Don’t forget that these techniques can easily be adapted to query &lt;EM&gt;any&lt;/EM&gt; Visual Studio project file, they’re only XML documents after all! Doubtless many people out there already have code for doing this but nonetheless here is another offering to the great script library in the sky. Have fun!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://twitter.com/jamiet"&gt;@Jamiet&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;This blog post was mentioned on &lt;/EM&gt;&lt;A href="http://channel9.msdn.com/Shows/This+Week+On+Channel+9/TWC9-AutoTuneNET-Portable-Libraries-Facebook--Azure-SQLR2-BI"&gt;&lt;EM&gt;This Week on Channel 9&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;. Fast forward to 10m49s.&lt;/EM&gt;&lt;/P&gt;</description></item><item><title>Some thoughts on Visual Studio database references and how they should be used for SQL Server BI</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/09/14/some-thoughts-on-visual-studio-database-references-and-how-they-should-be-used-for-sql-server-bi.aspx</link><pubDate>Tue, 14 Sep 2010 12:53:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:28755</guid><dc:creator>jamiet</dc:creator><description>&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;Over the past few weeks I have been making heavy use of the Database tools in Visual Studio 2010 (formerly known as datadude, DBPro, VSTS for Database Professionals or one of a plethora of other names that it has gone by over the past few years) and one of the features that has most impressed me has been database references.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;o:p&gt;Database references allow you to have stored procedures in your database project that refer to objects (tables, views, stored procedures etc…) that exist in other database projects and hence when you build your database project it is able to &lt;I style="mso-bidi-font-style:normal;"&gt;resolve&lt;/I&gt; those references. Gert Drapers has a useful introduction to them at his blog post &lt;A href="http://blogs.msdn.com/b/gertd/archive/2007/07/26/database-references.aspx"&gt;Database References&lt;/A&gt;; in his words database references allow you to:&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-LEFT:36pt;"&gt;&lt;SPAN class=apple-style-span&gt;&lt;I style="mso-bidi-font-style:normal;"&gt;&lt;SPAN style="FONT-SIZE:9pt;COLOR:#333333;FONT-FAMILY:'Segoe UI','sans-serif';"&gt;represent and resolve 3 and/or 4-part name usage inside a database project. Database references&amp;nbsp;are conceptually the same as assembly references inside a C# or VB.NET projects; they allow you to reference objects from your database project that live inside another namespace (database).&lt;/SPAN&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;I style="mso-bidi-font-style:normal;"&gt;&lt;/I&gt;&lt;SPAN class=apple-style-span&gt;&lt;I style="mso-bidi-font-style:normal;"&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;o:p&gt;It occurred to me that similar functionality would be incredibly useful for SQL Server Integration Services(SSIS), Analysis Services (SSAS) &amp;amp; Reporting Services (SSRS) projects. After all reports, packages and data source views are rife with references to database objects – why shouldn’t we be able to have design-time dependency checking in our BI projects the same way that database and .Net developers do?&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=Apple-style-span style="FONT-SIZE:11px;FONT-FAMILY:Verdana, sans-serif;"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=Apple-style-span style="FONT-SIZE:11px;FONT-FAMILY:Verdana, sans-serif;"&gt;Here are some examples of ways in which this would be useful:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;SPAN class=apple-style-span&gt;If a SSRS report pulls data from a view, I firstly want to know (at design-time) that that view exists. Secondly, if the view definition changes I want to know that my report will still work.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;SPAN class=apple-style-span&gt;&lt;/SPAN&gt;&lt;SPAN class=apple-style-span&gt;Similarly for a SSAS cube, if a view referenced in the DSV changes or disappears I want my SSAS project build to fail or succeed accordingly&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;SPAN class=apple-style-span&gt;&lt;/SPAN&gt;&lt;SPAN class=apple-style-span&gt;Similarly for a SSIS Execute SQL Task, if it executes a stored procedure I want to know that the named parameters that I am using actually exist in the stored procedure.&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;To this end I have submitted three identical suggestions to &lt;A href="http://connect.microsoft.com/sqlserver/feedback"&gt;Connect&lt;/A&gt;, one each for SSIS, SSAS &amp;amp; SSRS:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN class=apple-style-span&gt;&lt;SPAN style="FONT-SIZE:8.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-SIZE:16.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';mso-fareast-font-family:'Times New Roman';mso-bidi-font-family:'Times New Roman';mso-font-kerning:18.0pt;mso-fareast-language:EN-GB;"&gt;&lt;A class="" href="https://connect.microsoft.com/SQLServer/feedback/details/597709/" target=_blank&gt;[SSAS] Declare database object dependencies&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:16.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;A class="" href="https://connect.microsoft.com/SQLServer/feedback/details/597707/" target=_blank&gt;[SSRS] Declare database object dependencies&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:16.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:16.5pt;COLOR:black;FONT-FAMILY:'Verdana','sans-serif';"&gt;&lt;A class="" href="https://connect.microsoft.com/SQLServer/feedback/details/597708/" target=_blank&gt;[SSIS] Declare database object dependencies&lt;/A&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;I have said before in my blog post &lt;A href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/01/12/the-sql-developer-gap-warning-rant-coming-up.aspx"&gt;The SQL developer gap&lt;/A&gt; that we database and BI developers deserve as much love from Microsoft as our .Net counterparts do and I’m of the opinion that providing design-time dependency checking across the full gamut of BI projects would be a huge step in the right direction. The holy grail is an object dependency graph from database tables all the way up through database views, database functions, stored procedures, DAL, ORM layer &amp;amp; business logic layer all the way through to presentation – I don’t know how long it will take but we will get there one day I am sure, hopefully sooner rather than later!&lt;/P&gt;
&lt;P class=MsoNormal&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;A href="http://twitter.com/jamiet"&gt;@JamieT&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;UPDATE: This feature (i.e. the ability to define dependencies on database objects at build time) is coming to the Entity Framework as confirmed in this Connect submission:&amp;nbsp;&lt;A class="" href="http://bit.ly/igmEiS"&gt;http://bit.ly/igmEiS&lt;/A&gt;. Let's hope the same comes to SSIS/SSAS/SSRS soon.&lt;/P&gt;</description></item></channel></rss>