<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Matthew's Corner of the World</title>
	<atom:link href="http://mbussa.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mbussa.wordpress.com</link>
	<description>.NET Experiences</description>
	<lastBuildDate>Tue, 06 Oct 2009 15:06:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mbussa.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Matthew's Corner of the World</title>
		<link>http://mbussa.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mbussa.wordpress.com/osd.xml" title="Matthew&#039;s Corner of the World" />
	<atom:link rel='hub' href='http://mbussa.wordpress.com/?pushpress=hub'/>
		<item>
		<title>List Database Names and Size in SQL Server</title>
		<link>http://mbussa.wordpress.com/2009/10/06/list-database-names-and-size-in-sql-server/</link>
		<comments>http://mbussa.wordpress.com/2009/10/06/list-database-names-and-size-in-sql-server/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 15:06:47 +0000</pubDate>
		<dc:creator>mbussa</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://mbussa.wordpress.com/?p=52</guid>
		<description><![CDATA[Here’s a quick and easy way to list each database name and size in an instance of SQL Server.  I’ve tested this on both SQL 2000 and 2005. sp_helpdb  This query produces the following output:  Hope this helps!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=52&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here’s a quick and easy way to list each database name and size in an instance of SQL Server.  I’ve tested this on both SQL 2000 and 2005.</p>
<pre class="brush: sql;">

sp_helpdb
</pre>
<p> This query produces the following output:</p>
<p><a href="http://mbussa.files.wordpress.com/2009/09/image2.png"><img style="display:inline;border-width:0;" title="image" src="http://mbussa.files.wordpress.com/2009/09/image_thumb2.png?w=482&#038;h=41" border="0" alt="image" width="482" height="41" /></a></p>
<p> Hope this helps!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mbussa.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mbussa.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mbussa.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mbussa.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mbussa.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mbussa.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mbussa.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mbussa.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mbussa.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mbussa.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mbussa.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mbussa.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mbussa.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mbussa.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=52&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mbussa.wordpress.com/2009/10/06/list-database-names-and-size-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c899518093aa70f23744107aaf70c64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbussa</media:title>
		</media:content>

		<media:content url="http://mbussa.files.wordpress.com/2009/09/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>LINQ to Text File</title>
		<link>http://mbussa.wordpress.com/2009/09/30/linq-to-text-file/</link>
		<comments>http://mbussa.wordpress.com/2009/09/30/linq-to-text-file/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 14:49:48 +0000</pubDate>
		<dc:creator>mbussa</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://mbussa.wordpress.com/?p=44</guid>
		<description><![CDATA[So you’ve been using Linq to SQL but did you know that you can use Linq to a Text File?  In this demo, I’ll show you how you can implement this and some practical uses for it. 1.  Export the following data into a CSV file.  For this example, we’re using the AdventureWorks database.  The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=44&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So you’ve been using Linq to SQL but did you know that you can use Linq to a Text File?  In this demo, I’ll show you how you can implement this and some practical uses for it.</p>
<p>1.  Export the following data into a CSV file.  For this example, we’re using the AdventureWorks database.  The following SQL statement was used to get the sample data below: </p>
<pre class="brush: sql;">SELECT EmployeeID, LoginID, Title, MaritalStatus, VacationHours FROM HumanResources.Employee</pre>
<p><a href="http://mbussa.files.wordpress.com/2009/09/image1.png"><img style="display:inline;border-width:0;" title="image" src="http://mbussa.files.wordpress.com/2009/09/image_thumb1.png?w=365&#038;h=87" border="0" alt="image" width="365" height="87" /></a></p>
<p>2.  Create a Windows Console Application in C# and create the class that maps to your file like the following:</p>
<pre class="brush: csharp;">

public class Employee
    {
        public int EmpID { get; set; }
        public string LoginID { get; set; }
        public string Title { get; set; }
        public string MaritalStatus { get; set; }
        public int VacationHours { get; set; }
    }
</pre>
<p>3.  Code that creates the query to get only those records where VacationHours &gt; 0.  We will also print out every line and then the last line will print out the number of records.</p>
<pre class="brush: csharp;">

var query = from e in
                           (from line in File.ReadAllLines(@&quot;C:\AdvWorksEmployees.csv&quot;)
                            let employeeRecord = line.Split(',')
                            select new Employee()
                                {
                                    EmpID = int.Parse(employeeRecord[0]),
                                    LoginID = employeeRecord[1],
                                    Title = employeeRecord[2],
                                    MaritalStatus = employeeRecord[3],
                                    VacationHours = int.Parse(employeeRecord[4])
                                })
                       where e.VacationHours &gt; 0
                       select e;

int rowCount = query.Distinct().Count();

foreach (var item in query)
{
     Console.WriteLine(&quot;{0}, {1}, {2}, {3}, {4}&quot;, item.EmpID, item.LoginID,   item.MaritalStatus, item.Title, item.VacationHours); 
 }

Console.WriteLine(&quot;Number of rows:  &quot; + rowCount);
</pre>
<p>4.  We’re done!!  Here’s the entire code file for reference:</p>
<pre class="brush: csharp;">

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TextToLinqDemo
{
    public class Employee
    {
        public int EmpID { get; set; }
        public string LoginID { get; set; }
        public string Title { get; set; }
        public string MaritalStatus { get; set; }
        public int VacationHours { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var query = from e in
                            (from line in File.ReadAllLines(@&quot;C:\AdvWorksEmployees.csv&quot;)
                             let employeeRecord = line.Split(',')
                             select new Employee()
                                 {
                                     EmpID = int.Parse(employeeRecord[0]),
                                     LoginID = employeeRecord[1],
                                     Title = employeeRecord[2],
                                     MaritalStatus = employeeRecord[3],
                                     VacationHours = int.Parse(employeeRecord[4])
                                 })
                        where e.VacationHours &gt; 0
                        select e;

            int rowCount = query.Distinct().Count();

            foreach (var item in query)
            {
                Console.WriteLine(&quot;{0}, {1}, {2}, {3}, {4}&quot;, item.EmpID, item.LoginID,
                                    item.MaritalStatus, item.Title, item.VacationHours);
            }

            Console.WriteLine(&quot;Number of rows:  &quot; + rowCount);
            Console.Read();
        }

    }
}
</pre>
<p> </p>
<p>Why would you use this?</p>
<ul>
<li>Need to import a file but only import select records in the file, this would be a good tool to filter out data before importing</li>
</ul>
<p>Other resources:  <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx">101 LINQ Samples</a> – great site to dig deeper into LINQ</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mbussa.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mbussa.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mbussa.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mbussa.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mbussa.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mbussa.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mbussa.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mbussa.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mbussa.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mbussa.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mbussa.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mbussa.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mbussa.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mbussa.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=44&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mbussa.wordpress.com/2009/09/30/linq-to-text-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c899518093aa70f23744107aaf70c64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbussa</media:title>
		</media:content>

		<media:content url="http://mbussa.files.wordpress.com/2009/09/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Observer Pattern in C#</title>
		<link>http://mbussa.wordpress.com/2009/09/10/observer-pattern-in-c/</link>
		<comments>http://mbussa.wordpress.com/2009/09/10/observer-pattern-in-c/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 19:27:56 +0000</pubDate>
		<dc:creator>mbussa</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Design Patterns]]></category>

		<guid isPermaLink="false">http://mbussa.wordpress.com/2009/09/10/observer-pattern-in-c/</guid>
		<description><![CDATA[The Observer Pattern in C# is a design pattern where an object (subject) notifies dependent objects (observers) automatically of any state changes.&#160; You can think of it as a Publish—&#62;Subscription type of idea where if you subscribe to a magazine, for instance, you receive the magazine.&#160; When your subscription runs out, the magazine is no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=41&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Observer Pattern in C# is a design pattern where an object (subject) notifies dependent objects (observers) automatically of any state changes.&#160; </p>
<p>You can think of it as a Publish—&gt;Subscription type of idea where if you subscribe to a magazine, for instance, you receive the magazine.&#160; When your subscription runs out, the magazine is no longer delivered.</p>
<p>Here are the key components to an Observer Pattern:</p>
<p>1.&#160; Subject – a value/object that, when changes, notifies the observers</p>
<p>2.&#160; Observer – objects that have subscribed to the Provider to be notified when it’s state has changed.</p>
<p>Some examples on when to use this would include the following:</p>
<ul>
<li>Weather – the weather statistics change and there’s a need to notify multiple observers (maybe multiple user interfaces) </li>
<li>Stocks – when a stock price changed, there’s a need to notify all of their investors (observers). </li>
</ul>
<p>Here is a C# console application coding example using a Stock as a Subject and Investors as observers:</p>
<p><a id="displayText" href="#">Show Code</a>
<div style="display:none;" id="code">
<pre>
<pre class="brush: csharp;">

&lt;font size=&quot;1&quot;&gt;using System;
using System.Collections.Generic;
using System.Text;

namespace ObserverPattern
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create MSFT stock (subject) and attach investors (observers)

            MSFT msft = new MSFT(&amp;quot;MSFT&amp;quot;, 120.00);

            //Attach each investor to the stock
            msft.Attach(new Investor(&amp;quot;Sorros&amp;quot;));
            msft.Attach(new Investor(&amp;quot;Berkshire&amp;quot;));

            // Fluctuating prices will notify investors
            msft.Price = 120.10;
            msft.Price = 121.00;
            msft.Price = 120.50;
            msft.Price = 120.75;
            // Wait for user

            Console.ReadKey();

        }
    }

    abstract class Stock
    {
        private string _symbol;
        private double _price;
        private List&lt;iinvestor&gt; _investors = new List&lt;iinvestor&gt;();

        //Constructor
        public Stock(string symbol, double price)
        {
            this._symbol = symbol;
            this._price = price;
        }

        public void Attach(IInvestor investor)
        {
            _investors.Add(investor);
        }

        public void Detach(IInvestor investor)
        {
            _investors.Remove(investor);
        }

        public void Notify()
        {
            foreach (IInvestor investor in _investors)
            {
                investor.Update(this);
            }

            Console.WriteLine(&amp;quot;&amp;quot;);
        }

        public double Price
        {
            get { return _price; }
            set
            {
                if (_price != value)
                {
                    _price = value;
                    Notify();
                }
            }
        }

        //Gets the Symbol
        public string Symbol
        {
            get { return _symbol; }
        }
    }

        class MSFT : Stock
        {
            public MSFT(string symbol, double price)
                : base(symbol, price)
            { }
        }

        interface IInvestor
        {
            void Update(Stock stock);
        }

        class Investor : IInvestor
        {
            private string _name;
            private Stock _stock;

            public Investor(string name)
            {
                this._name = name;
            }

            public void Update(Stock stock)
            {
                Console.WriteLine(&amp;quot;Notified {0} of {1}'s &amp;quot; + &amp;quot;change to {2:C}&amp;quot;, _name, stock.Symbol, stock.Price);
            }

            public Stock stock
            {
                get { return _stock; }
                set { _stock = value; }
            }
        }
    }
&lt;/font&gt;
</pre>
</pre>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mbussa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mbussa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mbussa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mbussa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mbussa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mbussa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mbussa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mbussa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mbussa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mbussa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mbussa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mbussa.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mbussa.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mbussa.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=41&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mbussa.wordpress.com/2009/09/10/observer-pattern-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c899518093aa70f23744107aaf70c64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbussa</media:title>
		</media:content>
	</item>
		<item>
		<title>CRM 3.0 / IE8 Unsupported Browser Version Error</title>
		<link>http://mbussa.wordpress.com/2009/09/10/crm-3-0-ie8-unsupported-browser-version-error/</link>
		<comments>http://mbussa.wordpress.com/2009/09/10/crm-3-0-ie8-unsupported-browser-version-error/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 15:42:00 +0000</pubDate>
		<dc:creator>mbussa</dc:creator>
				<category><![CDATA[CRM]]></category>
		<category><![CDATA[IE8]]></category>

		<guid isPermaLink="false">http://mbussa.wordpress.com/2009/09/10/crm-3-0-ie8-unsupported-browser-version-error/</guid>
		<description><![CDATA[When attempting to log into CRM 3.0 with Internet Explorer 8, I receive the following error for an unsupported browser version:&#160; I noticed this happened after I installed Microsoft Office Live Add-In. Solution:&#160; Type the url as http://[servername]/loader.aspx instead of http://[servername]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=36&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When attempting to log into CRM 3.0 with Internet Explorer 8, I receive the following error for an unsupported browser version:&#160; </p>
<p><a href="http://mbussa.files.wordpress.com/2009/09/image.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://mbussa.files.wordpress.com/2009/09/image_thumb.png?w=244&#038;h=140" width="244" height="140" /></a> </p>
<p>I noticed this happened after I installed Microsoft Office Live Add-In.</p>
<p>Solution:&#160; Type the url as <font color="#0000ff">http://[servername]/loader.aspx</font> instead of <font color="#0000ff">http://[servername]</font></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mbussa.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mbussa.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mbussa.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mbussa.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mbussa.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mbussa.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mbussa.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mbussa.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mbussa.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mbussa.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mbussa.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mbussa.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mbussa.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mbussa.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=36&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mbussa.wordpress.com/2009/09/10/crm-3-0-ie8-unsupported-browser-version-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c899518093aa70f23744107aaf70c64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbussa</media:title>
		</media:content>

		<media:content url="http://mbussa.files.wordpress.com/2009/09/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Find Duplicates in SQL</title>
		<link>http://mbussa.wordpress.com/2009/08/19/find-duplicates-in-sql/</link>
		<comments>http://mbussa.wordpress.com/2009/08/19/find-duplicates-in-sql/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 15:53:34 +0000</pubDate>
		<dc:creator>mbussa</dc:creator>
				<category><![CDATA[1]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://mbussa.wordpress.com/?p=26</guid>
		<description><![CDATA[Have you ever wanted to know how to quick discover if you have duplicates in a SQL table? Here’s a SQL code snippet that will do exactly that: SELECT Employee, Count(Employee) AS NumOccurrences FROM table GROUP BY Employee HAVING (Count(Employee) &#62; 1) You can also order them by the number of duplicates you have like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=26&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to know how to quick discover if you have duplicates in a SQL table?</p>
<p>Here’s a SQL code snippet that will do exactly that:</p>
<pre>SELECT Employee, Count(Employee) AS NumOccurrences

FROM table

GROUP BY Employee

HAVING (Count(Employee) &gt; 1)

You can also order them by the number of duplicates you have like this:
SELECT Employee, Count(Employee) AS NumOccurrences

FROM table

GROUP BY Employee

HAVING (Count(Employee) &gt; 1)

ORDER BY (Count(Employee)) DESC
This little trick was taken from a Microsoft entry that also explains <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;139444">How to Remove Duplicate Rows from a table in SQL</a></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mbussa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mbussa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mbussa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mbussa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mbussa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mbussa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mbussa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mbussa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mbussa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mbussa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mbussa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mbussa.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mbussa.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mbussa.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=26&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mbussa.wordpress.com/2009/08/19/find-duplicates-in-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c899518093aa70f23744107aaf70c64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbussa</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL 2005 CLR:  Determine if a user is part of a particular Active Directory Group</title>
		<link>http://mbussa.wordpress.com/2009/03/12/18/</link>
		<comments>http://mbussa.wordpress.com/2009/03/12/18/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 14:19:20 +0000</pubDate>
		<dc:creator>mbussa</dc:creator>
				<category><![CDATA[SQL CLR]]></category>

		<guid isPermaLink="false">http://mbussa.wordpress.com/2009/03/12/18/</guid>
		<description><![CDATA[I wanted to create a SQL User defined function that would determine if a user is part of a particular Active Directory group. I set out to accomplish this task via CLR. Here are the steps to perform this: 1.  Open Visual Studio 2005 -&#62; New Project -&#62; Visual C# -&#62; Database -&#62; SQL Server [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=18&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to create a SQL User defined function that would determine if a user is part of a particular Active Directory group. I set out to accomplish this task via CLR. Here are the steps to perform this:</p>
<p>1.  Open Visual Studio 2005 -&gt; New Project -&gt; Visual C# -&gt; Database -&gt; SQL Server Project -&gt; OK</p>
<p>2.  Add a Database Reference: Enter SQL Server name, credentials, and database name -&gt; OK</p>
<p>3.  Accept the prompt to enable CLR debugging in the database.</p>
<p>4.  In the Solution Explorer window, right click on your Project name -&gt; Add -&gt; User Defined Function -&gt; save it as &#8220;IsUserPartOfADGroup.cs&#8221; (this will be the name of your function)</p>
<p>5.  Copy and paste the following code into the &#8220;IsUserPartOfADGroup.cs window:</p>
<pre class="brush: csharp;">
 

using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;

using System.DirectoryServices;
using System.Collections;

public partial class UserDefinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlInt16 IsUserPartOfADGroup(string username, string GroupToCheck)
    {
        string[] ary = username.ToString().Split('\');
        return Check_If_Member_Of_AD_Group(ary[1].ToString(),
                                                        GroupToCheck.Trim(),
                                                        ary[0].ToString(),
                                                        &quot;&quot;,
                                                        &quot;&quot;);
    }

    public static SqlInt16 Check_If_Member_Of_AD_Group(string username,
                                                            string grouptoCheck,
                                                            string domain,
                                                            string adlogin,
                                                            string adpassword)
    {

        try
        {
            //Sets up the connection string
            string entryString = &quot;LDAP://&quot; + domain;
            DirectoryEntry de;

            grouptoCheck = grouptoCheck.ToLower();

            if (adlogin != &quot;&quot; &amp;&amp; adpassword != &quot;&quot;)
            {
                de = new DirectoryEntry(entryString, adlogin, adpassword);
            }
            else
            {
                de = new DirectoryEntry(entryString);
            }

            DirectorySearcher myDirectorySearcher = new DirectorySearcher(de);
            myDirectorySearcher.Filter = &quot;sAMAccountName=&quot; + username;
            myDirectorySearcher.PropertiesToLoad.Add(&quot;MemberOf&quot;);

            SearchResult myResult = myDirectorySearcher.FindOne();

            int numberOfGroups = myResult.Properties[&quot;MemberOf&quot;].Count - 1;
            string tmpString;

            while (numberOfGroups &gt;= 0)
            {
                tmpString = myResult.Properties[&quot;MemberOf&quot;][numberOfGroups].ToString();
                tmpString = tmpString.Substring(0, tmpString.IndexOf(&quot;,&quot;, 0));

                tmpString = tmpString.Replace(&quot;CN=&quot;, &quot;&quot;);
                tmpString = tmpString.ToLower();
                tmpString = tmpString.Trim();

                if (grouptoCheck == tmpString)
                {
                    return 1; //return true
                }

                numberOfGroups = numberOfGroups - 1;
            }

            return 0; //return false
        }

        catch (Exception ex)
        {
            string parms = &quot;UserName:  &quot; + username + &quot;rnGroupToCheck: &quot; + grouptoCheck + &quot;rnDomain:  &quot; + domain + &quot;rnADLogin:  &quot; + adlogin;
            WriteError(parms, ex.Message.ToString());

            return -1; //Error
        }
    }

    public static void WriteError(string parameters, string errorMsg)
    {
        //Creates a Souce in the Application Log
        string source = &quot;SQL UDF&quot;;

        if (!System.Diagnostics.EventLog.SourceExists(source))
        {
            System.Diagnostics.EventLog.CreateEventSource(source, &quot;Application&quot;);
        }

        System.Diagnostics.EventLog aLog = new System.Diagnostics.EventLog();
        aLog.Source = source;
        aLog.WriteEntry(&quot;Error checking if user is a part of an AD Group:  rn Parameters:  rn&quot; + parameters + &quot;rnError Message:  &quot; + errorMsg.ToString(), System.Diagnostics.EventLogEntryType.Error);
    }

};
</pre>
<p>6.  Save. In Solution Explorer , right click on the name of your project and click Properties -&gt; Select Database from left hand side -&gt; Choose Permission Level to &#8220;Unsafe&#8221;.</p>
<ul>
<li>Note:  Not choosing &#8220;Unsafe&#8221; resulted in throwing a security exception when you attempt to run the UDF from SQL.</li>
</ul>
<p>7.  Open SQL Server Management Studio and execute the following command using the name of the database you are using from step 2.</p>
<pre class="brush: sql;">

EXEC sp_configure ‘CLR ENABLED’, ‘1’
GO
RECONFIGURE
GO
ALTER Database DatabaseName SET TRUSTWORTHY ON
GO
</pre>
<p>8.  Since we are using the System.DirectoryServices namespace, we need to allow SQL to recognize this as an assembly</p>
<pre class="brush: sql;">
SET NOCOUNT ON
GO
USE Master
GO
CREATE ASYMMETRIC KEY SystemDirectoryServicesKey FROM EXECUTABLE FILE = 'C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.DirectoryServices.dll'
GO
--create logins for special goals
CREATE LOGIN SQLCLRSysDirServLogin FROM ASYMMETRIC KEY SystemDirectoryServicesKey
GO&lt;/pre&gt;
-- grant necessary (UNSAFE) permissions
GRANT UNSAFE ASSEMBLY TO SQLCLRSysDirServLogin
GO
USE
GO

CREATE ASSEMBLY [System.DirectoryServices]
FROM 'C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.DirectoryServices.dll'
WITH PERMISSION_SET = UNSAFE
GO
</pre>
<p>9.  Go back to Visual Studio, select the &#8220;Debug&#8221; drop down and change that to &#8220;Release&#8221;.</p>
<p>10. Save. Hit F5. Visual Studio will both build it and deploy it automatically to the database specified.</p>
<p>11. In SQL Management Studio, query your database with the following statement:</p>
<pre class="brush: sql;">
SELECT IsUserPartOfADGroup(‘domainnameusername’, ‘Group To Check’)
</pre>
<p>A note:</p>
<ul>
<li>This function is meant to return a 1 if the specified user does exist in the specified Active Directory group, a 0 if not, and -1 if an error occurred. If an error occurred, it will right it in the Windows Event Log.</li>
</ul>
<p>Further Resources:</p>
<p><a href="http://blogs.msdn.com/ikovalenko/archive/2007/03/22/how-to-avoid-1000-rows-limitation-when-querying-active-directory-ad-from-sql-2005-with-using-custom-code.aspx">How to Avoid 1000 Rows limitation when querying Active Directory</a> – deals with additional Active Directory functions</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mbussa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mbussa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mbussa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mbussa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mbussa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mbussa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mbussa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mbussa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mbussa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mbussa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mbussa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mbussa.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mbussa.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mbussa.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=18&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mbussa.wordpress.com/2009/03/12/18/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c899518093aa70f23744107aaf70c64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbussa</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello World from Word 2007</title>
		<link>http://mbussa.wordpress.com/2008/10/29/hello-world-from-word-2007/</link>
		<comments>http://mbussa.wordpress.com/2008/10/29/hello-world-from-word-2007/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 14:42:50 +0000</pubDate>
		<dc:creator>mbussa</dc:creator>
				<category><![CDATA[SQL CLR]]></category>

		<guid isPermaLink="false">http://mbussa.wordpress.com/2008/10/29/hello-world-from-word-2007/</guid>
		<description><![CDATA[Hello: This is my first experience in the world of blogging and hope to bring some ideas and technical knowledge to the web as the web has been a major help in my development. I&#8217;m writing this from Word 2007 since it&#8217;s able to plug-into WordPress.com. I believe I should start out by introducing myself: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=3&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello:
</p>
<p>This is my first experience in the world of blogging and hope to bring some ideas and technical knowledge to the web as the web has been a major help in my development.  I&#8217;m writing this from Word 2007 since it&#8217;s able to plug-into WordPress.com.
</p>
<p>I believe I should start out by introducing myself:  I&#8217;m currently engaged to the most wonderful woman in the world and we are getting married in December.  I&#8217;m currently working as a Software Developer near Columbus, Ohio developing custom solutions and customizations working primarily with all things Microsoft.  My company specializes in Microsoft Dynamics SL, GP, and CRM.  I love learning and experimenting with new technologies and hope to blog about some of my experiences here.
</p>
<p>I hope you enjoy.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mbussa.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mbussa.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mbussa.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mbussa.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mbussa.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mbussa.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mbussa.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mbussa.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mbussa.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mbussa.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mbussa.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mbussa.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mbussa.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mbussa.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mbussa.wordpress.com&amp;blog=5339231&amp;post=3&amp;subd=mbussa&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mbussa.wordpress.com/2008/10/29/hello-world-from-word-2007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7c899518093aa70f23744107aaf70c64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mbussa</media:title>
		</media:content>
	</item>
	</channel>
</rss>
