<?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 'SQL 2008' and 'SSRS'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=SQL+2008,SSRS&amp;orTags=0</link><description>Search results matching tags 'SQL 2008' and 'SSRS'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Here Comes the FY11 Earmarks Database</title><link>http://sqlblog.com/blogs/michael_coles/archive/2010/12/18/fy11-earmarks-database.aspx</link><pubDate>Sun, 19 Dec 2010 04:51:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:31753</guid><dc:creator>Mike C</dc:creator><description>&lt;P&gt;&lt;IMG style="WIDTH:85px;HEIGHT:73px;" title=Republicrat alt=Republicrat src="http://brprfa.bay.livefilestore.com/y1pjC6aA55VxtLxZxeO9XgEgt9tWZwDf5FIWCGhQRu2zHM_0ELo4mdYVJ0BfS80wFRUIQiaM25IXkmU1fHFxwFCPXH-0YUJOIFf/republicrat.jpg" width=374 height=385&gt;I'm really interested in politics (don't worry, I'm not going to start bashing politicians and hammering you with&amp;nbsp;political rage).&amp;nbsp; The point is when the U.S.&amp;nbsp;&lt;A title="Omnibus Spending Bill, Full Text" href="http://appropriations.senate.gov/news.cfm?method=news.view&amp;amp;id=9ac3518e-7e19-4328-bf52-16a6c2a1d333"&gt;FY11 Omnibus Spending Bill&lt;/A&gt; (the bill to fund the U.S. Government for another year) was announced it piqued my interest.&amp;nbsp; I'm fascinated by "&lt;A title="Earmarks Definition" href="http://en.wikipedia.org/wiki/Earmark_(politics)"&gt;earmarks&lt;/A&gt;" (also affectionally known as "&lt;A title="Pork Barrel Politics" href="http://en.wikipedia.org/wiki/Pork_(politics)"&gt;pork&lt;/A&gt;").&amp;nbsp; For those who aren't familiar with U.S. politics, "earmark" is a slang term for "Congressionally Directed Spending".&amp;nbsp; It's basically the set of provisions added to bills by Senators and Representatives in the U.S.&amp;nbsp;Congress, directing money to be spent on certain programs or projects without all the hassle of introducing a separate bill, sending it through umpteen committees, and getting enough supporters in both chambers to vote it up.&amp;nbsp; Most of the time Senators and Representatives introduce earmarks that send money back to their home states (see &lt;A title="The Earmark Master" href="http://en.wikipedia.org/wiki/Senator_Byrd"&gt;this guy&lt;/A&gt; for details).&lt;BR&gt;&lt;BR&gt;Now it looks like the Omnibus Bill is dead for now, but the record of the earmarks is still available at &lt;A href="http://appropriations.senate.gov/news.cfm"&gt;http://appropriations.senate.gov/news.cfm&lt;/A&gt;&amp;nbsp;in PDF format&amp;nbsp;(no, you don't have to visit Wikileaks).&amp;nbsp; Just look for the "Earmarks" links at the bottom of the page under "All News Items".&amp;nbsp; So what I have been doing the past few days, since the bill was announced, is loading the earmarks into a SQL database.&amp;nbsp; It turned out to be a little more complex than it should have been.&amp;nbsp; There was the issue of extracting the data out of the PDF files, normalizing it, ETLing it into SQL Server, cleaning it up (a *lot* of manual cleanup required), adding and cleaning up reference data, and finally linking the earmarks to the reference data.&lt;BR&gt;&lt;BR&gt;You can download the resulting SQL 2008 database backup file &lt;A title="Sample Earmarks Database" href="http://sqlblog.com/blogs/michael_coles/attachment/31753.ashx"&gt;from this post&lt;/A&gt; and restore it to your test server to play around with.&amp;nbsp; Here are some sample queries I ran:&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;SUM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;e&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Amount&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Earmark e&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;U&gt;Result:&lt;BR&gt;&lt;/U&gt;&lt;/STRONG&gt;8313820025&lt;BR&gt;&lt;BR&gt;(That's $8.3 Billion dollars in earmarks -- note that some earmarks did not specify $ amounts, so this number is low)&lt;BR&gt;&lt;BR&gt;Want to see total earmarks requested by party affiliation?&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;WITH&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; CTE&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;AS&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;DISTINCT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; e&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;EarmarkID&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; e&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Amount&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Party&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Earmark e&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;&amp;nbsp; INNER&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;JOIN&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;EarmarkCongress ec&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; e&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;EarmarkID &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ec&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;EarmarkID&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;&amp;nbsp; INNER&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;JOIN&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Congress c&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ec&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;CongressID &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;CongressID&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; Party&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;SUM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Amount&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; CTE&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;GROUP&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;BY&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; Party&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;U&gt;Results:&lt;BR&gt;&lt;/U&gt;&lt;/STRONG&gt;D, 6779032457&lt;BR&gt;R, 2933829318&lt;BR&gt;I, 216149500&lt;BR&gt;&lt;BR&gt;This one actually double-counts some items since&amp;nbsp;the same earmark can be sponsored by a Democrat (D), a Republican (R), and/or an Independent (I) all at the same time.&lt;BR&gt;&lt;BR&gt;And if you want to see how much was requested by your Senators and Representatives:&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;SELECT&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Chamber&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;LastName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;FirstName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Party&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;SUM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;e&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Amount&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;FROM&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Earmark e&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;INNER&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;JOIN&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;EarmarkCongress ec&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; ON&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; e&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;EarmarkID &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ec&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;EarmarkID&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;INNER&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;JOIN&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Congress c&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; ON&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ec&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;CongressID &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;CongressID&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;WHERE&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;State&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;'NJ'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;GROUP&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;BY&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Chamber&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;LastName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;FirstName&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp; c&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Party&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;U&gt;Results:&lt;BR&gt;&lt;/U&gt;&lt;/STRONG&gt;House, Adler,&amp;nbsp;John&amp;nbsp;D,&amp;nbsp;23848125&lt;BR&gt;House,&amp;nbsp;Andrews,&amp;nbsp;Rob&amp;nbsp;D,&amp;nbsp;27710000&lt;BR&gt;House,&amp;nbsp;Holt,&amp;nbsp;Rush&amp;nbsp;D,&amp;nbsp;103953000&lt;BR&gt;House,&amp;nbsp;Pallone,&amp;nbsp;Frank&amp;nbsp;D,&amp;nbsp;21810000&lt;BR&gt;House,&amp;nbsp;Pascrell,&amp;nbsp;Bill&amp;nbsp;D,&amp;nbsp;15143000&lt;BR&gt;House,&amp;nbsp;Payne,&amp;nbsp;Donald&amp;nbsp;D,&amp;nbsp;52908000&lt;BR&gt;House,&amp;nbsp;Rothman,&amp;nbsp;Steven&amp;nbsp;D,&amp;nbsp;107153000&lt;BR&gt;House,&amp;nbsp;Sires,&amp;nbsp;Albio&amp;nbsp;D,&amp;nbsp;120141000&lt;BR&gt;Senate,&amp;nbsp;Lautenberg, &amp;nbsp;Frank&amp;nbsp;D,&amp;nbsp;239061125&lt;BR&gt;Senate,&amp;nbsp;Menendez, &amp;nbsp;Bob&amp;nbsp;D,&amp;nbsp;243982125&lt;BR&gt;&lt;BR&gt;Again there can be double-counting since an earmark can have multiple sponsors (very likely when you're talking about Senators and Representatives from the same state).&lt;BR&gt;&lt;BR&gt;Also note that I had to add in the non-voting Congressional delegates from U.S. territories (Puerto Rico, U.S. Virgin Islands, Guam, etc.) and Washington, D.C. to the reference data.&amp;nbsp; They don't vote, but they're allowed to attach earmarks to bills to bring some cash back home.&lt;BR&gt;&lt;BR&gt;I'd love to see what others are able to do with &lt;A title="Earmarks Sample Database" href="http://sqlblog.com/blogs/michael_coles/attachment/31753.ashx"&gt;this data&lt;/A&gt;.&amp;nbsp; Some ideas -- use Reporting Services to map earmarks across the country; come up with clever queries to allocate earmarks equally across sponsors to avoid the double-counting issues; some Top n style queries by amounts, counts, etc.; combine it with spatial data and other reference data out there; compare things like # of sponsors for an earmark vs. the amount of the earmark, or seniority of sponsors vs. the amount of the earmark; maybe do something clever with it in PowerPivot.&amp;nbsp; If you find this type of data interesting and you download the database to play with, let&amp;nbsp;us know the results and what you come up with.&lt;BR&gt;&lt;BR&gt;&lt;IMG style="WIDTH:608px;HEIGHT:579px;" title="Democracy - It's what's for dinner" alt="Democracy - It's what's for dinner" src="http://4.bp.blogspot.com/_Dui8IAY9uqg/Sg10oA-0SuI/AAAAAAAAEME/j2Lf9toIcmI/s1600/Democracy.jpg" width=608 height=579&gt;&lt;/P&gt;</description></item><item><title>T-SQL Tuesday #005: Creating SSMS Custom Reports</title><link>http://sqlblog.com/blogs/michael_coles/archive/2010/04/12/t-sql-tuesday-005-creating-ssms-custom-reports.aspx</link><pubDate>Tue, 13 Apr 2010 00:14:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:24228</guid><dc:creator>Mike C</dc:creator><description>&lt;P&gt;This is my&amp;nbsp;contribution to the T-SQL Tuesday blog party, started by &lt;A title="Adam Machanic" href="http://sqlblog.com/blogs/adam_machanic/archive/2010/04/05/t-sql-tuesday-005-reporting.aspx"&gt;Adam Machanic&lt;/A&gt; and &amp;nbsp;hosted this month by &lt;A title="Aaron Nelson" href="http://sqlvariant.com/wordpress/index.php/2010/04/t-sql-tuesday-005-reporting/"&gt;Aaron Nelson&lt;/A&gt;.&amp;nbsp; Aaron announced this month's topic is "reporting" so I figured I'd throw a blog up on a reporting topic I've been interested in for a while -- namely creating custom reports in SSMS.&lt;/P&gt;
&lt;P&gt;Creating SSMS custom reports isn't difficult, but&amp;nbsp;like most technical work it's very detailed with a lot of little steps involved.&amp;nbsp; So this post is a little longer than usual and includes a lot of screenshots.&amp;nbsp; There's also a downloadable &lt;A title="Sample SSMS Custom Reports" href="http://brprfa.bay.livefilestore.com/y1pu65YtRksdmF-NkqPRSNVJVjP75MjU31Yyvna97r9AoEdF9wilfgmWTFCpm7DDuuPRpS9qe9Io-h4_pms-Y2N0LV1L6j8bNeU/Custom%20Report%20Samples.zip?download"&gt;ZIP file&lt;/A&gt; with the projects from this article included.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;SSMS Custom Reports&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL Server 2008 and 2005 both offer custom report functionality in Management Studio.&amp;nbsp; With a little bit of work you can create custom SSMS reports just like the standard reports that Microsoft ships with Management Studio.&amp;nbsp; The Disk Usage Report shown below is just one of the many standard reports that comes with SSMS.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:591px;HEIGHT:496px;" title="SSMS Standard Report" alt="SSMS Standard Report" src="http://brprfa.bay.livefilestore.com/y1p96w-RdpK_UPoOGMgli4eVbzYi3Oj9d-SdGVX4zXdkABiCseQUqv8_Ye9DjYtHHdaJj39eOK0XzLEqnctlccDKSptvHhJME1c/standard-report.jpg" width=591 height=496&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Creating a Report Project&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SSMS uses the SQL Server Reporting Services (SSRS) 2005 client/viewer control to render both standard and custom reports.&amp;nbsp; This is true for both SSMS 2005 and SSMS 2008.&amp;nbsp; So the first step to building a custom SSMS report is to fire up Visual Studio 2005 and create a new &lt;EM&gt;Report Server Project&lt;/EM&gt; as shown below.&amp;nbsp; For this example we'll create a custom report that lists missing indexes, so give the project the name &lt;I&gt;Missing Index&lt;/I&gt;.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:550px;HEIGHT:305px;" title="Create New Project Dialog" alt="Create New Project Dialog" src="http://brprfa.bay.livefilestore.com/y1pkwKN2ypKEv3XJHROh7xaoTOi4R79ha01zyZnL-acBQhieH_6CAo18PEri6DjOBX5d_O2jgH6bPTvIOUWNpmr7eHf-4xxG_GI/vs2005-new-project.jpg" width=550 height=305&gt;&lt;/P&gt;
&lt;P&gt;Once you create the &lt;EM&gt;Report Server Project&lt;/EM&gt; right-click on &lt;I&gt;Reports&lt;/I&gt; in the Solution Explorer and choose &lt;I&gt;Add &amp;gt; New Item...&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:286px;HEIGHT:258px;" title="Add Report to Project" alt="Add Report to Project" src="http://brprfa.bay.livefilestore.com/y1p8qFbsxsFq7xjtkvppNWQ-N7S5R-uoHiJif6FtkChY1pzf5qQblwl7AapydMWrSRFY1_O-XsadEk5nR6XV9DX7-2lJVp7TFWn/add-report.jpg" width=286 height=258&gt;&lt;/P&gt;
&lt;P&gt;When the &lt;I&gt;Add New Item&lt;/I&gt; box appears, choose the Report template and give the report a name.&amp;nbsp;&amp;nbsp;For this example I named the report&amp;nbsp;&lt;I&gt;Missing Index.rdl&lt;/I&gt; - the &lt;EM&gt;.rdl&lt;/EM&gt; extension stands for "Report Definition Language", and is the standard extension for SSRS report definition files.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:551px;HEIGHT:244px;" title="Add Report Dialog" alt="Add Report Dialog" src="http://brprfa.bay.livefilestore.com/y1pf_VVyzWAjA0uiWHfEChyN-uwUNscnR9B5cHDipw1KDF1StNazv-T7xFtmGqtdgBVZ1kGS_daR5vqkPFk-QdqpWMVdDR5Nodv/add-report-box.jpg" width=551 height=244&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Defining the Report Dataset&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once the report is added to your project you have to add a new dataset to the report.&amp;nbsp; The dataset defines the structure and content of the source data that will populate your report.&amp;nbsp; Choose &lt;I&gt;&amp;lt;New Dataset...&amp;gt;&lt;/I&gt; from the &lt;I&gt;Dataset:&lt;/I&gt; dropdown.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:470px;HEIGHT:151px;" title="Add New Dataset dropdown" alt="Add New Dataset dropdown" src="http://brprfa.bay.livefilestore.com/y1pw8BZ2mr9F4SCExKCklLxVPczZu6Mq0IEo2agULy1QRoLJRF2KKDqVAv1Oft41oQu1oBaZd_iEMa91OfLT83Eeky87qAra11Z/add-new-dataset.jpg" width=470 height=151&gt;&lt;/P&gt;
&lt;P&gt;Visual Studio will respond with a &lt;EM&gt;Data Source&lt;/EM&gt; box.&amp;nbsp; Just make sure the &lt;I&gt;Type:&lt;/I&gt; dropdown is set to the default &lt;STRONG&gt;Microsoft SQL Server&lt;/STRONG&gt; and put &lt;STRONG&gt;Data Source=.&lt;/STRONG&gt; in the &lt;I&gt;Connection string:&lt;/I&gt; box.&amp;nbsp; This is all that's required since the SSMS custom report you're creating will use connections created and managed by SSMS's Object Explorer.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:569px;HEIGHT:487px;" title="Add Datasource Dialog" alt="Add Datasource Dialog" src="http://brprfa.bay.livefilestore.com/y1pZ9v1Nf3IVwj1bm5gCsMnZLstJyKbsLFI75DOGhsuGjcuHZalsEs2c_odVbbgaqiWQpwyYZkyRBc3BExbXiZweT67vn5FhBgN/add-data-source.jpg" width=569 height=487&gt;&lt;/P&gt;
&lt;P&gt;After you define the data source, you can define the SQL query that will populate your report.&amp;nbsp; Just put the query in the dataset window as shown below.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:703px;HEIGHT:358px;" title="Adding a Dataset" alt="Adding a Dataset" src="http://brprfa.bay.livefilestore.com/y1pfTvR7VFHggCKt2l8yVZ_2vlxY9-ZppnqW2MEJIDTQvzy1X7zhLg43LfaTKpRB2QI5rlzv_TcpiCKkbXPh7WQZL5d-a6PNLdP/add-new-dataset3.jpg" width=703 height=358&gt;&lt;/P&gt;
&lt;P&gt;I borrowed (and slightly modified) the following query from &lt;A title="Brent Ozar!" href="http://www.brentozar.com/"&gt;Brent Ozar&lt;/A&gt;.&amp;nbsp; He originally published it at &lt;A title=SQLServerPedia! href="http://sqlserverpedia.com/wiki/Find_Missing_Indexes"&gt;SQLServerPedia&lt;/A&gt;. &amp;nbsp;This particular query uses SQL Server's missing index Dynamic Management Views (DMVs) to identify missing indexes.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;-- Begin missing index query&lt;BR&gt;&lt;BR&gt;WITH cte&lt;BR&gt;AS&lt;BR&gt;(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT mid.object_id AS object_id,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUOTENAME(OBJECT_SCHEMA_NAME(mid.object_id)) AS table_schema,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUOTENAME(OBJECT_NAME(mid.object_id)) AS table_name,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QUOTENAME('IX_' + OBJECT_SCHEMA_NAME(mid.object_id) + '_' +&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; LEFT(CAST(NEWID() AS CHAR(36)), 8)) AS index_name,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mid.index_handle&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM sys.dm_db_missing_index_details mid&lt;BR&gt;)&lt;BR&gt;SELECT&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DENSE_RANK() OVER&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ORDER BY cte.table_schema, cte.table_name&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) AS table_color,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROW_NUMBER() OVER&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARTITION BY cte.table_schema, cte.table_name&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) DESC&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) AS index_color,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cte.table_schema,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cte.table_name,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cte.index_name AS index_name,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) AS calc_impact,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'CREATE NONCLUSTERED INDEX ' + cte.index_name + ' ON ' +&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cte.table_schema + '.' + cte.table_name +&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' (' + COALESCE(mid.equality_columns, '') +&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CASE WHEN mid.inequality_columns IS NULL&amp;nbsp;&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; THEN ''&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; ELSE CASE WHEN mid.equality_columns IS NULL&amp;nbsp;&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; THEN ''&amp;nbsp;&amp;nbsp;&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; ELSE ','&amp;nbsp;&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; END + mid.inequality_columns&amp;nbsp;&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; END +&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ') ' + CASE WHEN mid.included_columns IS NULL&amp;nbsp;&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; THEN ''&amp;nbsp;&amp;nbsp;&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; ELSE 'INCLUDE (' + mid.included_columns + ')'&amp;nbsp;&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; END +&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ';' AS create_stmt,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mid.equality_columns,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mid.inequality_columns,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mid.included_columns &lt;BR&gt;FROM sys.dm_db_missing_index_group_stats AS migs &lt;BR&gt;INNER JOIN sys.dm_db_missing_index_groups AS mig&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON migs.group_handle = mig.index_group_handle &lt;BR&gt;INNER JOIN sys.dm_db_missing_index_details AS mid&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON mig.index_handle = mid.index_handle&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND mid.database_id = DB_ID() &lt;BR&gt;INNER JOIN cte&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON cte.index_handle = mid.index_handle&lt;BR&gt;WHERE migs.group_handle IN &lt;BR&gt;(&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT group_handle&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM sys.dm_db_missing_index_group_stats WITH (NOLOCK) &lt;BR&gt;)&lt;BR&gt;ORDER BY calc_impact DESC;&lt;BR&gt;&lt;BR&gt;-- End missing index query&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;There are a couple of caveats to keep in mind about the missing index DMVs that this query relies on:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;They're not designed to be exhaustive.&amp;nbsp; If you want to get a serious analysis of useful indexes in your databases, you definitely want to use a tool that will perform a more extensive analysis.&lt;/LI&gt;
&lt;LI&gt;The DMVs only persist their information since the last time the SQL Server service was restarted.&amp;nbsp; If you've recently restarted the service you'll get very little information back.&amp;nbsp; These DMVs are best to use when your server has been running under normal load for a while.&lt;/LI&gt;
&lt;LI&gt;The suggestions returned by the DMVs aren't always the best way to go.&amp;nbsp; These DMVs often recommend suggested indexes with lots of overlap (lots of columns in common, often in similar order).&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;To put it another way, don't take the raw information returned by these DMVs at face value.&amp;nbsp; The information they return is definitely useful for determining where indexes might provide benefit if your system has been running under normal load for a while, and the redundant index suggestions tend to indicate which indexes might be most useful.&amp;nbsp; But these DMVs just amount to a starting point for analyzing your indexing needs.&amp;nbsp; I'd recommend against creating dozens of redundant&amp;nbsp;indexes based on the raw output of these DMVs.&lt;/P&gt;
&lt;P&gt;Visual Studio will normally populate the dataset fields.&amp;nbsp; If for some reason it doesn't, you can manually edit the fields by hitting the&amp;nbsp;&lt;IMG style="WIDTH:12px;HEIGHT:11px;" title="Edit Selected Dataset button" alt="Edit Selected Dataset button" src="http://brprfa.bay.livefilestore.com/y1p1RjlRPeT8nUiaHkby2NgdTPdwAZhlX8j1xno7j2uXjLVrCXDh4iCA3tat3aKVR2mak4Anfa_irdyFjJ8vd1qRUXFznVjXJLl/edit-selected-dataset.jpg" width=25 height=22&gt;&amp;nbsp;&lt;I&gt;Edit Selected Dataset&lt;/I&gt; button to pull up the &lt;I&gt;Dataset&lt;/I&gt; window.&amp;nbsp; You can then enter the field names on the &lt;I&gt;Fields&lt;/I&gt; tab if they aren't already populated.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:388px;HEIGHT:319px;" title="Edit Dataset Fields tab" alt="Edit Dataset Fields tab" src="http://brprfa.bay.livefilestore.com/y1pfvnIF4EbFtuA6q8rBYk0t072J_cDu43NCKGn3DGtJepbF5Xtr-qqAQ23gcmmMQr94DH295woheHjRbkSBuXMC-oHJsxPlDoL/dataset-fields.jpg" width=554 height=458&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Building the Report&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far most of what we've done is just setup.&amp;nbsp; With this&amp;nbsp;done, it's time to design and build the actual report.&amp;nbsp; For this, click on the Visual Studio &lt;EM&gt;Layout&lt;/EM&gt; tab to get to the report designer surface.&amp;nbsp; You can drag and drop text boxes, charts, tables, images and any other controls from the Toolbox onto the designer surface.&amp;nbsp; To keep it simple we'll just drag a text box and a table onto the designer.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:685px;HEIGHT:341px;" title="Reprot Designer Layout tab" alt="Reprot Designer Layout tab" src="http://brprfa.bay.livefilestore.com/y1pWNM-fc_9Nr_h6im9m8v9jweJclU9QXhuvkIMwSDMxkaDXMq_QqvgLUJN3wtzqqQil54T4aTHvvDOFPupnH2D_i0WQAhx9u2G/report-designer-1.jpg" width=685 height=341&gt;&lt;/P&gt;
&lt;P&gt;Put the title of the report in the text box (in this case "Missing Index Report") and format it to your liking.&amp;nbsp; The table we dragged onto the designer surface has three columns by default.&amp;nbsp; For this example we want six columns total.&amp;nbsp; To add more columns right-click on the top border of the table and choose &lt;I&gt;Insert Column to the Left&lt;/I&gt; to add a new column.&amp;nbsp; Repeat two more times.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:516px;HEIGHT:265px;" title="Inserting columns in SSRS table" alt="Inserting columns in SSRS table" src="http://brprfa.bay.livefilestore.com/y1pMVVRej-iyVngxatXV5eZNwxe42KRX3loOI5AMNbJYNPvaQLwNPdA2_rEfbFqaXJ1M827zxGteCq8wtIkw8mJmOigbBDgloik/insert-columns.jpg" width=831 height=459&gt;&lt;/P&gt;
&lt;P&gt;In the &lt;I&gt;Header&lt;/I&gt; row of the table we'll type in the headers for each column like the following:&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:577px;HEIGHT:173px;" title="Editing Table Column Headers in a report" alt="Editing Table Column Headers in a report" src="http://brprfa.bay.livefilestore.com/y1pclRRkvyQ58kZth8uxowVdjARwR9LROwxTNmOxKph-la2SwSyk5UdkLqGTrgDQVNk1bi-Q4A9YX_8RUluiCHCba_EI6APPNOz/report-column-headers.jpg" width=968 height=303&gt;&lt;/P&gt;
&lt;P&gt;In the &lt;I&gt;Detail&lt;/I&gt; row we'll put in the formulas to populate the database fields like this:&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:579px;HEIGHT:181px;" title="Editing the Report Table Details" alt="Editing the Report Table Details" src="http://brprfa.bay.livefilestore.com/y1pCcKPNTXmgXVchY8WkAtQYF-L5iPN8g65mJC8cHhd0fJ7O3tPx4iAHmhWO7XrQG8VXQ-c2p-pUE01v5noF_nqihOBBaQ9d15j/report-column-details.jpg" width=968 height=303&gt;&lt;/P&gt;
&lt;P&gt;SSRS formulas begin with the equal sign (&lt;STRONG&gt;=&lt;/STRONG&gt;).&amp;nbsp; Fields from the dataset are referenced directly using the format &lt;EM&gt;&lt;STRONG&gt;Fields!field_name.Value&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Deploying and Running the Report&lt;/U&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At this point use Visual Studio to build the project.&amp;nbsp; Once it builds without error, navigate to the project directory in Windows Explorer and copy the &lt;I&gt;Missing Index.rdl&lt;/I&gt; file to the SSMS Custom Reports directory (on my computer this directory is located at &lt;EM&gt;C:\Users\Michael\Documents\SQL Server Management Studio\Custom Reports&lt;/EM&gt;, it'll be different on yours).&amp;nbsp; &lt;/P&gt;
&lt;P&gt;You can now bring up this report in SSMS by right-clicking on a database in the Object Explorer and selecting &lt;I&gt;Reports &amp;gt; Custom Reports...&lt;/I&gt; to select the custom report.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:350px;HEIGHT:322px;" title="Running a Custom Report in SSMS" alt="Running a Custom Report in SSMS" src="http://brprfa.bay.livefilestore.com/y1pXFRn1jsLwq2U9tpYrjStVVVnrG-A7RO2mZfEAd_tZPMUVN1X3VRrc81PtQl8l0TcHgCFIMa3dPDSb1qhAxRvyxu8vL94iaPB/run-custom-report.jpg" width=567 height=551&gt;&lt;/P&gt;
&lt;P&gt;Choose your custom report from the file selection box and click &lt;I&gt;Open&lt;/I&gt;.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:543px;HEIGHT:340px;" title="Selecting a Custom Report in SSMS" alt="Selecting a Custom Report in SSMS" src="http://brprfa.bay.livefilestore.com/y1pwUOidWktlB26rl2DefIcRZ4YzSDVRUwqZ3IqFDNh3mAEvNg9Fs-Gy8k8m5lnVJfSPm3dEb6GNQpOXGdsK2u1ABViZ4cHivzr/choose-custom-report.jpg" width=864 height=543&gt;&lt;/P&gt;
&lt;P&gt;When you run a custom report in SSMS you'll get a warning like the following:&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:306px;HEIGHT:186px;" title="SSMS Custom Report Warning Box" alt="SSMS Custom Report Warning Box" src="http://brprfa.bay.livefilestore.com/y1pj7c9vCxvKz3cPrIDZuL5EIvxHJGN6FlCspgGan0cZdd08mvzz0CKuUbdxcfbKA-hPSJU4F9pP6BJb08s1vLqurCuKhYMWDHe/custom-report-warning.jpg" width=420 height=256&gt;&lt;/P&gt;
&lt;P&gt;Just choose &lt;EM&gt;Run&lt;/EM&gt;.&amp;nbsp; You might also want to check the box that says "&lt;EM&gt;Please don't show this warning again&lt;/EM&gt;" to keep the box from popping up every time you run a custom report.&amp;nbsp; The simple custom report you've created looks like the one shown below.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:593px;HEIGHT:254px;" title="Simple Custom Report" alt="Simple Custom Report" src="http://brprfa.bay.livefilestore.com/y1pTSsqYVoiCmzuzPOOHutMQnibG2CwxjGijBWma-J9VL3XPF1P0CpVzbQUUbGUj9vXmYh0avAt7armpL4BnSvxub7pcAq8xT3O/simple-report.jpg" width=964 height=453&gt;&lt;/P&gt;
&lt;P&gt;You can use images, color and other formatting techniques to make the report easier to read and use, and more flexible for your users.&amp;nbsp; Consider the image below, which is a screenshot of a reformatted version of the &lt;EM&gt;Missing Index&lt;/EM&gt; report.&amp;nbsp; This one includes more information, color and collapsible sections.&amp;nbsp; Both reports are included in the attached &lt;A title="SSMS Custom Reports" href="http://brprfa.bay.livefilestore.com/y1pu65YtRksdmF-NkqPRSNVJVjP75MjU31Yyvna97r9AoEdF9wilfgmWTFCpm7DDuuPRpS9qe9Io-h4_pms-Y2N0LV1L6j8bNeU/Custom%20Report%20Samples.zip?download"&gt;ZIP file&lt;/A&gt; under the Missing Index and Missing Index Color directories.&lt;/P&gt;
&lt;P&gt;&lt;IMG style="WIDTH:601px;HEIGHT:488px;" title="Reformatted SSMS Custom Report" alt="Reformatted SSMS Custom Report" src="http://brprfa.bay.livefilestore.com/y1pHxjPdr2Zd4nKD0hsBC6T0BTOiIH15VmH6pfwHt3jfrod1z_bQ_dqEx6eDfZKCTt66KotLSPQXOOrX7F40Lwc3T05ZBCZGypG/final-report-color.jpg" width=991 height=810&gt;&lt;/P&gt;
&lt;P&gt;You can play around with the source files included in the attached &lt;A title="Sample SSMS Custom Reports" href="http://brprfa.bay.livefilestore.com/y1pu65YtRksdmF-NkqPRSNVJVjP75MjU31Yyvna97r9AoEdF9wilfgmWTFCpm7DDuuPRpS9qe9Io-h4_pms-Y2N0LV1L6j8bNeU/Custom%20Report%20Samples.zip?download" target=_blank&gt;ZIP file&lt;/A&gt;.&lt;/P&gt;</description></item><item><title>It's Official - SQLSaturday is Coming to NYC!</title><link>http://sqlblog.com/blogs/michael_coles/archive/2010/02/06/it-s-official-sqlsaturday-is-coming-to-nyc.aspx</link><pubDate>Sat, 06 Feb 2010 19:59:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:21916</guid><dc:creator>Mike C</dc:creator><description>&lt;P&gt;&lt;A title="NJSQL Home Page" href="http://www.njsql.org/" target=_blank&gt;New Jersey SQL Server User Group (NJSQL)&lt;/A&gt; is bringing &lt;A title="SQLSaturday #39 Home Page" href="http://www.sqlsaturday.com/39/eventhome.aspx" target=_blank&gt;SQLSaturday #39&lt;/A&gt;&amp;nbsp;to NYC on April 24, 2010!&amp;nbsp; The free all-day training event will be hosted by Microsoft at their Midtown Manhattan offices.&amp;nbsp; The speaker line-up is growing fast—if you'd like to present, visit the event's open &lt;A title="SQLSaturday #39 Call for Speakers" href="http://www.sqlsaturday.com/39/callforspeakers.aspx" target=_blank&gt;call for speakers&lt;/A&gt;.&amp;nbsp;&amp;nbsp;This is a free full-day training&amp;nbsp;event, but &lt;A title="SQLSaturday #39 Registration Page" href="http://www.sqlsaturday.com/39/register.aspx" target=_blank&gt;registration is required&lt;/A&gt;&amp;nbsp;to attend.&amp;nbsp; Seating is limited.&lt;/P&gt;
&lt;P&gt;Registration, speaker, and sponsorship details are posted at &lt;A href="http://www.sqlsaturday.com/39/eventhome.aspx"&gt;http://www.sqlsaturday.com/39/eventhome.aspx&lt;/A&gt;.&lt;/P&gt;</description></item></channel></rss>