<?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/"
	>

<channel>
	<title>Andrew den Hertog</title>
	<atom:link href="http://andrewdenhertog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewdenhertog.com</link>
	<description>WPF .NET C# SQL Server MVC blog</description>
	<lastBuildDate>Sun, 28 Aug 2011 07:03:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Mp3 vocabulary generator</title>
		<link>http://andrewdenhertog.com/hacks/mp3-vocabulary-generator/</link>
		<comments>http://andrewdenhertog.com/hacks/mp3-vocabulary-generator/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 07:03:43 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://andrewdenhertog.com/?p=285</guid>
		<description><![CDATA[A quick hack that generates an Mp3 file based on a set of vocabulary. Find it at http://language.andrewdenhertog.com]]></description>
			<content:encoded><![CDATA[<p>A quick hack that generates an Mp3 file based on a set of vocabulary. Find it at <a href="http://language.andrewdenhertog.com">http://language.andrewdenhertog.com</a></p>
<g:plusone href="http://andrewdenhertog.com/hacks/mp3-vocabulary-generator/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/hacks/mp3-vocabulary-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turn your computer into an internet TV</title>
		<link>http://andrewdenhertog.com/hacks/turn-computer-internet-tv/</link>
		<comments>http://andrewdenhertog.com/hacks/turn-computer-internet-tv/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 00:04:15 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://andrewdenhertog.com/?p=283</guid>
		<description><![CDATA[Stream continuous, best of the web video to your computer. Use your iPhone to remotely control the computer from anywhere in the world. All you need is an Internet connection, so why not try it out and see for yourself.]]></description>
			<content:encoded><![CDATA[<p><a href="http://YouTube.andrewdenhertog.com"></p>
<p>Stream continuous, best of the web video to your computer. Use your iPhone to remotely control the computer from anywhere in the world. </p>
<p>All you need is an Internet connection, so why not try it out and see for yourself.</p>
<g:plusone href="http://andrewdenhertog.com/hacks/turn-computer-internet-tv/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/hacks/turn-computer-internet-tv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create DependencyProperty in WPF in 5 minutes</title>
		<link>http://andrewdenhertog.com/c/create-dependencyproperty-dependencyobject-5-minutes/</link>
		<comments>http://andrewdenhertog.com/c/create-dependencyproperty-dependencyobject-5-minutes/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 01:22:33 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[DependencyObject]]></category>
		<category><![CDATA[DependencyProperty]]></category>

		<guid isPermaLink="false">http://andrewdenhertog.com/?p=267</guid>
		<description><![CDATA[Have you tried to create a DependencyProperty on one of your UserControl or DependencyObject in WPF only to find that your extra bits of code don&#8217;t get run when you raise PropertyChanged? This will take you through everything you need &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/c/create-dependencyproperty-dependencyobject-5-minutes/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Have you tried to create a DependencyProperty on one of your UserControl or DependencyObject in WPF only to find that your extra bits of code don&#8217;t get run when you raise PropertyChanged? This will take you through everything you need to do in order to fire custom code on the PropertyChagned event.</p>
<p>First, create your class and inherit from DependencyObject, or create a new UserControl that inherits DependencyProperty.</p>
<p>Next, create a DependencyProperty using the code snippet propdp and hitting TAB:</p>
<pre>        public int Age
        {
            get { return (int)GetValue(AgeProperty); }
            set { SetValue(AgeProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Age.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty AgeProperty =
            DependencyProperty.Register("Age", typeof(int), typeof(Person), new UIPropertyMetadata(0));</pre>
<p>At this point, you&#8217;d think that you can modify the Age property&#8217;s access modifiers. Not the case.</p>
<p>Instead, you need to create a callback to handle the PropertyChanged event and attach this to the DepedencyProperty. Here&#8217;s the completed definition:</p>
<pre>        public int Age
        {
            get { return (int)GetValue(AgeProperty); } //do NOT modify anything in here
            set { SetValue(AgeProperty, value); } //...or here
        }

        // Using a DependencyProperty as the backing store for Age.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty AgeProperty =
            DependencyProperty.Register(
            "Age",  //Must be the same name as the property created above
            typeof(int), //Must be the same type as the property created above
            typeof(Person), //Must be the same as the owner class
            new UIPropertyMetadata(
                0,  //default value, must be of the same type as the property
                new PropertyChangedCallback((s, e) =&gt;  //A callback that gets executed when the property changed
                {
                    var source = s as Person;
                    s.DOB_Year = DateTime.Now.Year - s.Age;
                })));</pre>
<p>Place your code in the callback, and it will get executed when the event is raised and the property has been changed.</p>
<p>Note that this is not thread safe, and you&#8217;ll need to use Dispatcher.Invoke to safely set other properties in this callback.</p>
<g:plusone href="http://andrewdenhertog.com/c/create-dependencyproperty-dependencyobject-5-minutes/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/c/create-dependencyproperty-dependencyobject-5-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating model associations in Rails</title>
		<link>http://andrewdenhertog.com/ruby-on-rails/creating-model-associations-in-rails/</link>
		<comments>http://andrewdenhertog.com/ruby-on-rails/creating-model-associations-in-rails/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 05:51:26 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://www.andrewdenhertog.com/?p=230</guid>
		<description><![CDATA[Model associations are an extremely important part of a rails app that identify how models interact with each other and the relationships between them. If you’ve ever worked with ORM providers, or even basic OO principles, then you’ll be able &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/ruby-on-rails/creating-model-associations-in-rails/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Model associations are an extremely important part of a rails app that identify how models interact with each other and the relationships between them. If you’ve ever worked with ORM providers, or even basic OO principles, then you’ll be able to pick this up very quickly.</p>
<p>This follows on from a previous post <a href="http://www.andrewdenhertog.com/ruby-on-rails/beginner-rails-creating-a-new-application">Beginner Rails – Creating a new application </a>where we’re looking at a simple implementation of a photo blog.</p>
<p>When you create a model in rails, it generally comes stock with nothing added except for the base definition of its properties and inherited methods. Models are located in the appmodels folder of your project, and inherit ActiveRecord::Base to provide it with the database-aware behaviors.</p>
<p> To illustrate how this works, we’ll implement the remaining two models from the previous post:</p>
<ul>
<li>Photo</li>
<li>Comment</li>
</ul>
<p>To create a model, you use the command:</p>
<pre>rails g model ModelName propertyName1:type1 propertyName2:type2</pre>
<p>So for the Photo model:</p>
<pre>rails g model Photo gallery_id:integer title:string</pre>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/1.bmp"><img class="alignnone size-full wp-image-233" title="1" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/1.bmp" alt="" /></a></p>
<p>You’ll notice that because photo belongs to a gallery, the gallery_id for that photo is created that’ll be used as a foreign key.</p>
<p>This creates the relevant model, tests and migration script. Use</p>
<pre>rake db:migrate</pre>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/21.png"><img class="alignnone size-full wp-image-234" title="2" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/21.png" alt="" width="504" height="142" /></a></p>
<p>to run the migration and create the photos table in the database</p>
<p>Now that the model has been created, we’ll create our first association. This association will be that a Photo belongs to a Gallery, and a Gallery can have many Photos.</p>
<p>To specify that a Photo belongs to a gallery, we make the change in appmodelsphoto.rb:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/31.png"><img class="alignnone size-full wp-image-235" title="3" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/31.png" alt="" width="289" height="45" /></a></p>
<p>And now to specify a Gallery has many photos, open up appmodelsgallery.rb:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/42.png"><img class="alignnone size-full wp-image-237" title="4" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/42.png" alt="" width="258" height="48" /></a></p>
<p>By adding two simple lines of code, ActiveRecord is now aware of the relationships between these entities and can work with objects far easier.</p>
<p> Let’s go into the console and try it out:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/51.png"><img class="alignnone size-full wp-image-238" title="5" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/51.png" alt="" width="599" height="160" /></a></p>
<p>Here we created a new gallery which creates it in memory, and then running the save() method which commits it to the database.</p>
<p>If you want to do the new and save procedure in one step, you can call the “create” method instead which we’ll now use to add some photos to this gallery:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/61.png"><img class="alignnone size-full wp-image-239" title="6" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/61.png" alt="" width="600" height="65" /></a></p>
<p>So now our database has 1 gallery that has 2 photos in it. We can leverage the associations we created before to navigate these objects:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/71.png"><img class="alignnone size-full wp-image-240" title="7" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/71.png" alt="" width="600" height="60" /></a></p>
<p>The next phase is to add the ability to create comments against these photos. The association is similar to the Gallery/Photo relationship with one addition: A comment belongs to a single photo, a photo can have many comments, and a gallery has many comments through its photos.</p>
<p>Let’s start by creating the Comment model:</p>
<pre>rails g model Comment photo_id:integer body:text</pre>
<pre>rake db:migrate</pre>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/81.png"><img class="alignnone size-full wp-image-241" title="8" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/81.png" alt="" width="483" height="283" /></a></p>
<p>Then modifying the Comment &amp; Photo models:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/91.png"><img class="alignnone size-full wp-image-242" title="9" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/91.png" alt="" width="268" height="48" /></a></p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/101.png"><img class="alignnone size-full wp-image-243" title="10" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/101.png" alt="" width="240" height="61" /></a></p>
<p>And then create a new association in the Gallery model that will retrieve all of the comments for all of the photos related to it:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/11.png"><img class="alignnone size-full wp-image-244" title="11" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/11.png" alt="" width="472" height="63" /></a></p>
<p>Once that’s done, reload the changes in your irb console by using:</p>
<pre>reload!</pre>
<p>And then add some comments to each photo:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/12.png"><img class="alignnone size-full wp-image-245" title="12" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/12.png" alt="" width="599" height="282" /></a></p>
<p>Now we can try out all of our associations, including the “by relation” ones from Gallery to Comment:</p>
<p><a href="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/13.png"><img class="alignnone size-full wp-image-232" title="13" src="http://www.andrewdenhertog.com/wp-content/uploads/2010/12/13.png" alt="" width="600" height="131" /></a></p>
<p>In this example, we looked at belongs_to and has_many associations, but the full list of associations Rails supports is:</p>
<ul>
<li>has_one</li>
<li>has_many</li>
<li>belongs_to</li>
<li>has_and_belongs_to_many</li>
</ul>
<p>Which is enough to define any type of association you have.</p>
<p>This is a very simple example, but these principles can be applied at a much larger scale to sufficiently manage all of your objects. The next post will define the validations that define the data rules for each object.</p>
<g:plusone href="http://andrewdenhertog.com/ruby-on-rails/creating-model-associations-in-rails/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/ruby-on-rails/creating-model-associations-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beginner Rails &#8211; Creating a new application</title>
		<link>http://andrewdenhertog.com/ruby-on-rails/beginner-rails-creating-a-new-application/</link>
		<comments>http://andrewdenhertog.com/ruby-on-rails/beginner-rails-creating-a-new-application/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 09:22:07 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://andrewdenhertog.com/?p=30</guid>
		<description><![CDATA[It’s quick to get up and running in ROR – more so than any other web stack. This example takes on a photo blog application to show the basic commands on getting a site up and running. First, declare a &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/ruby-on-rails/beginner-rails-creating-a-new-application/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>It’s quick to get up and running in ROR – more so than any other web stack. This example takes on a photo blog application to show the basic commands on getting a site up and running.</p>
<p>First, declare a new project using the command:</p>
<pre>rails new photoblog –d mysql</pre>
<p> </p>
<p>The –d mysql option tells rails to create a new project preconfigured to use mysql. It’s your choice what you use, and the complete set of choices are:</p>
<pre>mysql/oracle/postgresql/sqlite3/frontbase/ibm_db</pre>
<p> </p>
<p>This generates the skeleton files needed for a rails app:</p>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/1.png"><img class="alignnone size-full wp-image-31" title="Create new rails application" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/1.png" alt="Create new rails application" width="452" height="847" /></a></p>
<p>The next step is to define our database connections. Open up config/database.yml:</p>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/2.png"><img class="alignnone size-full wp-image-32" title="Modify database.yml file" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/2.png" alt="Modify database.yml file" width="424" height="622" /></a></p>
<p>If you’re using a different provider, your configuration file will be different. Check over the defaults and make any necessary changes.</p>
<p>Once your connections have been defined, we need to create them. Rather than doing it ourselves, we’ll get rake to do this for us.</p>
<p> rake db:create:all</p>
<p>When this finishes, you’ll notice that rake has created the databases for all environments:</p>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/3.png"><img class="alignnone size-full wp-image-33" title="Database tables created" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/3.png" alt="Database tables created" width="232" height="74" /></a></p>
<p>So that’s the basic setup and configuration of a rails app. The next step is to create the entities for our application. In this photoblog app, we’ll create 3 entities:</p>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/4.png"><img class="alignnone size-full wp-image-34" title="Application entities" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/4.png" alt="Application entities" width="512" height="144" /></a></p>
<p>We’ll have a number of galleries, that each contain some photos, and each photo can have comments attached against it.</p>
<p> In development it’s easiest to create entities in order of their dependence. That is, create objects that don’t depend on anything else and work backwards from there. In this case, the entities will be created:</p>
<ol>
<li>Gallery</li>
<li>Photo</li>
<li>Comment</li>
</ol>
<p> </p>
<p>We’ll use a process in rails called scaffolding to get the Gallery set up. Scaffolding is a quick and dirty method to get a basic set of MVC objects together to interact with an entity.</p>
<p>To do this for the Gallery entity, use:</p>
<pre>rails generate scaffold Gallery title:string</pre>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/5.png"><img class="alignnone size-full wp-image-35" title="Rails generate scaffold" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/5.png" alt="Rails generate scaffold" width="447" height="328" /></a></p>
<p>2 things about this – firstly we didn’t explicitly create an id field (this is handled implicitly for all rails objects), secondly rails automatically pluralizes all of your entity names.</p>
<p>At this point all of these files exist, but the database doesn’t have the “galleries” table created. This is a convention of rails where models are created in a migration script (under db/migrate), and need to be applied to your database using the command:</p>
<pre>rake db:migrate</pre>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/6.png"><img class="alignnone size-full wp-image-36" title="Rails migrate database" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/6.png" alt="Rails migrate database" width="487" height="140" /></a></p>
<p>If you open these migration scripts, you’ll notice there’s no SQL. This makes it dead easy to switch to different database providers later on without having to retrofit all of your code.</p>
<p>At this point you can check out your basic gallery page by booting up your web server. To get a list of all of the links in your site, use:</p>
<pre>rake routes</pre>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/7.png"><img class="alignnone size-full wp-image-37" title="Rake routes" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/7.png" alt="Rake routes" width="580" height="168" /></a></p>
<p>By default, RoR comes bundled with a WEBrick server, so to start it up all you need to do is:</p>
<pre>rails server</pre>
<p> </p>
<p>The server starts up on: <a href="http://127.0.0.1:3000/">http://127.0.0.1:3000</a>, and a visit to one of the routes (eg: <a href="http://127.0.0.1:3000/galleries">http://127.0.0.1:3000/galleries</a>) can be seen in the console:</p>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/8.png"><img class="alignnone size-full wp-image-38" title="Start rails web server" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/8.png" alt="Start rails web server" width="506" height="226" /></a></p>
<p>As well as your browser:</p>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/9.png"><img class="alignnone size-full wp-image-39" title="Example rails scaffold 1" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/9.png" alt="" width="626" height="437" /></a><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/10.png"><img class="alignnone size-full wp-image-40" title="Example rails scaffold 2" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/10.png" alt="Example rails scaffold 2" width="626" height="437" /></a></p>
<p>Pretty basic, unstyled site. The next post will have a deeper look into model relationships, and how to gain more control over your application development without using scaffolding.</p>
<g:plusone href="http://andrewdenhertog.com/ruby-on-rails/beginner-rails-creating-a-new-application/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/ruby-on-rails/beginner-rails-creating-a-new-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introduction to Ruby on Rails</title>
		<link>http://andrewdenhertog.com/ruby-on-rails/introduction-to-ruby-on-rails/</link>
		<comments>http://andrewdenhertog.com/ruby-on-rails/introduction-to-ruby-on-rails/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 07:49:24 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://andrewdenhertog.com/?p=21</guid>
		<description><![CDATA[Ruby on Rails (ROR) is a web framework that uses the Ruby language to build database-agnostic websites very quickly. As far as agile web development goes, ROR is one of if not the fastest way to iteratively build a site. &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/ruby-on-rails/introduction-to-ruby-on-rails/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Ruby on Rails (ROR) is a web framework that uses the Ruby language to build database-agnostic websites very quickly. As far as agile web development goes, ROR is one of if not the fastest way to iteratively build a site.</p>
<p>ROR is very strongly governed by the laws of DRY (“Don’t Repeat Yourself”) and Convention over Configuration. In other words, if you develop using ROR the way it’s intended, you should see very high returns on your effort.</p>
<p>The basic architecture of a rails app looks like this:</p>
<p><a href="http://andrewdenhertog.com/wp-content/uploads/2010/12/ruby_architecture.png"><img class="alignnone size-full wp-image-22" title="rails_architecture" src="http://andrewdenhertog.com/wp-content/uploads/2010/12/ruby_architecture.png" alt="Ruby on Rails Architecture" width="368" height="423" /></a></p>
<p>These are some of the major components. A rails app includes:</p>
<ul>
<li><strong>Ruby</strong> – the programming language used</li>
<li><strong>Rails</strong> – the web framework</li>
<li><strong>Web server</strong> – WEBrick is the default, but Passenger is the de facto standard for production environments</li>
<li><strong>Database</strong> – Rails interacts with many different databases through adapters. This achieves the ultimate goal of being able to switch databases at any point without changing any code.</li>
<li><strong>ActiveRecord</strong> – The standard ORM that handles the mappings of database rows to Ruby objects.</li>
<li><strong>ActiveResource</strong> – Allows ruby apps to connect to each other or other REST based web servers.</li>
<li><strong>MVC stack</strong> – The standard separation of responsibilities for the views, models and controllers implemented in a lot of different languages and frameworks</li>
</ul>
<p>Rails also includes a bunch of other modules, tools and concepts that I haven’t touched on here for the sake of simplicity, but this should be enough to provide a basic understanding.</p>
<p>Ruby by itself is a very readable language. Due to a very light sprinkling of syntactic symbols is generally easy to comprehend even by non development types. This makes it ideal for development/BA types/Customers to verify correct behaviors in the code.</p>
<p>The selling point of ROR is the speed it takes to get a high quality site up and running quickly. This is different from many other web stacks such as ASP.NET (incl ASP.NET MVC), PHP, CF where the database is still treated very much as an “outside” component of a website that’s maintained separately.</p>
<p>Due to ActiveRecord, rails generation and rake migrations; each change is incremental and includes both a repeatable upgrade/downgrade task that is database agnostic.</p>
<p>Add to this a very test-centric approach to development, cross platform support and significantly lifting of the framework of a lot of the plumbing code, getting a serious app up and running quickly is a reality of ROR.</p>
<p>However, ROR is not without its disadvantages – the most popular of which is proper hosting support. Although not a shortcoming of rails in itself, many web hosts have treated rails hosting as something that just needs to be installed so it can be added on their feature sheet. The result can be very shaky rails apps. If you’re looking for a good host, consider a ruby-centric host such as:</p>
<p><a href="http://www.hostingrails.com/">www.hostingrails.com</a></p>
<p><a href="http://www.heroku.com/">www.heroku.com</a></p>
<p><a href="http://www.engineyard.com/">www.engineyard.com</a></p>
<p>Ruby is a very simple language that’s easy to learn and easy to read. Coupled with the Rails framework results in a very fast and agile way to get web applications up and running.</p>
<p>If you’re a Django/Pylons/ASP.NET/JSP/PHP developer interested in what ROR has to offer, then it’s worthwhile spending a couple of days working through of the thousands of online tutorials to see how a Rails evolves.</p>
<p>At this point, even if you decide Rails isn’t for you, you will hopefully touch on many of the standard design principles it’s based on that can be applied to any language.</p>
<g:plusone href="http://andrewdenhertog.com/ruby-on-rails/introduction-to-ruby-on-rails/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/ruby-on-rails/introduction-to-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reporting Services (SSRS) – Get data value into page header/footer</title>
		<link>http://andrewdenhertog.com/reporting-services/reporting-services-ssrs-get-data-value-into-page-headerfooter/</link>
		<comments>http://andrewdenhertog.com/reporting-services/reporting-services-ssrs-get-data-value-into-page-headerfooter/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 12:19:01 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Reporting Services]]></category>

		<guid isPermaLink="false">http://www.andrewdenhertog.com/?p=171</guid>
		<description><![CDATA[In reporting services (ssrs), there are times where you need to get a value from a data source and put it into your page header/footer. The catch here is that ssrs does not allow you to access data sources within &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/reporting-services/reporting-services-ssrs-get-data-value-into-page-headerfooter/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>In reporting services (ssrs), there are times where you need to get a value from a data source and put it into your page header/footer. The catch here is that ssrs does not allow you to access data sources within your header/footer. This is one way around it.</p>
<p>First the easy but inflexible way.</p>
<ol>
<li>Create a textbox in the body of the report &amp; set the value to what you want appearing in your header/footer</li>
<li>Set the name of your textbox to txtVarStore</li>
<li>In the properties of this textbox, set Visibility -&gt; Hidden to True (ie: hide the textbox)</li>
<li>Create a textbox in your header/footer &amp; set the value to the expression: &#8220;<font face="Courier New">=ReportItems!txtVarStore.Value</font>&#8220;</li>
</ol>
<p>This will set the value of the textbox in your header/footer; but will only do it for the page that the hidden textbox is on.</p>
<p>The second way is a bit more involved, but persists across pages:</p>
<ol>
<li>Go to Properties of your report</li>
<li>Go to the Code tab</li>
<li>Create a new public shared variable for your value, ie:
<ol>
<li><font face="Courier New">Public Shared Dim MyVar as String</font></li>
</ol>
</li>
<li>Create a new function to set the value of this variable, ie:
<ol>
<li><font face="Courier New">Public Function SetMyVar ( ByVar var as String)</font></li>
<li><font face="Courier New">   MyVar = var</font></li>
<li><font face="Courier New">End Function</font></li>
</ol>
</li>
<li>Create a new textbox in the body of your report &amp; set the value to the expression: <font size="1"><span lang="ZH"> <font size="2" face="Courier New">&#8220;=Code.SetMyVar(First(Fields!colVar.Value, &#8220;DataSourceName&#8221;))&#8221;</font></span></font></li>
<li>Create a new textbox in your header/footer, set the value to the expression: <font face="Courier New">&#8220;=Code.MyVar&#8221;</font></li>
</ol>
<p>What this does is set up a new static variable (shared variable for you VB ppl), which persists once across the entire report. In SSRS, the body content gets generated first, which is why we can set the static variable using the SetMyVar function.</p>
<p>When it comes time for the header/footer to render, it simply reads out the value of the static variable. </p>
<p>Bit of a sleazy hack, but such are the quirks of SSRS</p>
<g:plusone href="http://andrewdenhertog.com/reporting-services/reporting-services-ssrs-get-data-value-into-page-headerfooter/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/reporting-services/reporting-services-ssrs-get-data-value-into-page-headerfooter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Importing CSV flat files in SSIS – dealing with Double Quotes</title>
		<link>http://andrewdenhertog.com/tips/importing-csv-flat-files-in-ssis-dealing-with-double-quotes/</link>
		<comments>http://andrewdenhertog.com/tips/importing-csv-flat-files-in-ssis-dealing-with-double-quotes/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 12:13:53 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.andrewdenhertog.com/?p=162</guid>
		<description><![CDATA[I&#8217;ve gone through a number of phases in SSIS. The first was fascination, the next was anger, then came love, and now I&#8217;m somewhere in the middle. One major flaw I&#8217;ve noticed is how SSIS handles double quotes (&#8220;) in &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/tips/importing-csv-flat-files-in-ssis-dealing-with-double-quotes/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gone through a number of phases in SSIS. The first was fascination, the next was anger, then came love, and now I&#8217;m somewhere in the middle. One major flaw I&#8217;ve noticed is how SSIS handles double quotes (&#8220;) in imported flat file data, or should I say how it doesn&#8217;t handle it at all?</p>
<p>Simple scenario, I have a *csv file that I&#8217;m importing to a db table. The flat file is all text delimited using double quotes. A number of the fields contain literal double quotes, which in any CSV text delmited implementation you would normally escape by using another double quote delimeter. To illustrate:</p>
<p>This: </p>
<p>he cried out &#8220;SSIS!&#8221; in frustration</p>
<p>Becomes This:</p>
<p>&#8220;he cried out &#8220;&#8221;SSIS!&#8221;" in frustration&#8221;</p>
<p>Simple, standard csv behaviour, parses fine in excel.</p>
<p>Try importing to SSIS and your import will crash out, and if you try to preview that row you&#8217;ll get: &#8220;T<font face="Arial">he flat file parser does not support embedding text qualifiers in data&#8221;</font></p>
<p>Solution? The only way I&#8217;ve found to get around this is to write your own escape functionality. I piggy-backed off html encoding and replaced literal quotes with &amp;quot;  , and then used derived columns with <font face="Arial">REPLACE(ImportedField,&#8221;&amp;quot;&#8221;,&#8221;"&#8221;) to change them back prior to putting them in their destination table.</font></p>
<p>I hate having to write work arounds like this, especially for functionality which should be part of the underlying core system. If anyone has a better way, please drop your comments in below. </p>
<g:plusone href="http://andrewdenhertog.com/tips/importing-csv-flat-files-in-ssis-dealing-with-double-quotes/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/tips/importing-csv-flat-files-in-ssis-dealing-with-double-quotes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sql Server – How to split time into n minute groups</title>
		<link>http://andrewdenhertog.com/sql-server/sql-server-how-to-split-time-into-n-minute-groups/</link>
		<comments>http://andrewdenhertog.com/sql-server/sql-server-how-to-split-time-into-n-minute-groups/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 12:13:20 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.andrewdenhertog.com/?p=160</guid>
		<description><![CDATA[Another little data manipulation I&#8217;ve had to do recently is to split a heap of sql server datetime values into 15 minute segments (eg: 10:00, 10:15, 10:30 etc). Although there&#8217;s no inherit function that I know about in sql server &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/sql-server/sql-server-how-to-split-time-into-n-minute-groups/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>Another little data manipulation I&#8217;ve had to do recently is to split a heap of sql server datetime values into 15 minute segments (eg: 10:00, 10:15, 10:30 etc). Although there&#8217;s no inherit function that I know about in sql server that achieves this, there&#8217;s a nifty little trick using the modulus operator (%) that can do this.</p>
<div style="FONT-SIZE: 9pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
<p style="MARGIN: 0px"><span style="COLOR: aqua">select</span></p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">case </span></p>
<p style="MARGIN: 0px">      <span style="COLOR: aqua">when datepart</span>(<span style="COLOR: aqua">hour</span>, DateTimeval) &lt; <span style="COLOR: yellow">12 </span><span style="COLOR: aqua">then </span><span style="COLOR: red">&#8216;AM&#8217; </span></p>
<p style="MARGIN: 0px">      <span style="COLOR: aqua">else </span><span style="COLOR: red">&#8216;PM&#8217;</span></p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">end as </span>Meridiem,</p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">Datepart</span>(<span style="COLOR: aqua">hour</span>, DateTimeval) <span style="COLOR: aqua">as Hour</span>,</p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">case </span></p>
<p style="MARGIN: 0px">      <span style="COLOR: aqua">when </span>(<span style="COLOR: aqua">datepart</span>(<span style="COLOR: aqua">minute</span>, DateTimeval) % <span style="COLOR: yellow">15 </span>) &lt; (<span style="COLOR: yellow">15 </span>/ <span style="COLOR: yellow">2</span>) <span style="COLOR: aqua">then datepart</span>(<span style="COLOR: aqua">minute</span>, DateTimeval) &#8211; (<span style="COLOR: aqua">datepart</span>(<span style="COLOR: aqua">minute</span>, DateTimeval) % <span style="COLOR: yellow">15</span>)</p>
<p style="MARGIN: 0px">      <span style="COLOR: aqua">else </span>(<span style="COLOR: aqua">datepart</span>(<span style="COLOR: aqua">minute</span>, DateTimeval) + (<span style="COLOR: yellow">15 </span>- (<span style="COLOR: aqua">datepart</span>(<span style="COLOR: aqua">minute</span>, DateTimeval) % <span style="COLOR: yellow">15</span>))) % <span style="COLOR: yellow">60</span></p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">end as </span>QuarterHour</p>
<p style="MARGIN: 0px"><span style="COLOR: aqua">from</span></p>
<p style="MARGIN: 0px">   MyTable</p>
</div>
<p>Where DateTimeval is the column that holds the&#8230; date time value.</p>
<p>Firstly the &lt; (15/2) part determines the range of the midpoints (ie: the midpoint 15 ranges from 7.5 to 22.5).  Next it gets the minutes part from the value (eg: 10, 49, 15, etc), then does % 15. This will give the remainders (10, 04, 00). If the remainder is less that the range value (ie: &lt; (15/2)), then by simply subtracting the remainder from the original value will give us the midpoint (eg: N/A, 49 &#8211; 4 = 45, 15 &#8211; 0 = 15). </p>
<p>If, however, the remainder is &gt; (15 / 2), then we need to add the difference of (15 &#8211; remainder) to get the upper midpoint value (eg: 10 + (15 &#8211; 10) = 5, 45, 15).</p>
<p>And voila, the date time values are segmented into 15 minute chunks.</p>
<p>Of course you can substitute 15 with however many minutes  you want to segment by (eg: 5, 10, 30 etc). </p>
<p>Performance has been Ok. I ran this over 200,000 records and it took about 3 seconds on a shared dev server. Not bad.</p>
<g:plusone href="http://andrewdenhertog.com/sql-server/sql-server-how-to-split-time-into-n-minute-groups/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/sql-server/sql-server-how-to-split-time-into-n-minute-groups/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generating List of Dates</title>
		<link>http://andrewdenhertog.com/sql-server/generating-list-of-dates/</link>
		<comments>http://andrewdenhertog.com/sql-server/generating-list-of-dates/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 12:13:03 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.andrewdenhertog.com/?p=158</guid>
		<description><![CDATA[At times, especially when working with cubes with date/time dimensions, it&#8217;s necessary for me to dynamically generate a list of date values for use in those dimensions. That single date dimension often services a number of cubes, and the range &#8230;<p class="read-more"><a href="http://andrewdenhertog.com/sql-server/generating-list-of-dates/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<p>At times, especially when working with cubes with date/time dimensions, it&#8217;s necessary for me to dynamically generate a list of date values for use in those dimensions. That single date dimension often services a number of cubes, and the range of date values can be determined from the min/max date values from serveral tables. </p>
<p>I&#8217;ve written the following SQL that will retrieve the min/max date values, and create a single record for every day in that min/max range. It&#8217;s useful to turn this sql into a view which will refresh itself automatically every time the cube calling it is processed.  </p>
<div style="FONT-SIZE: 9pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
<p style="MARGIN: 0px"><span style="COLOR: aqua">select</span></p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">date</span>,</p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">datename</span>(dw, <span style="COLOR: aqua">date</span>)</p>
<p style="MARGIN: 0px">   + <span style="COLOR: red">&#8216;, &#8216; </span>+ <span style="COLOR: aqua">datename</span>(mm, <span style="COLOR: aqua">date</span>)</p>
<p style="MARGIN: 0px">   + <span style="COLOR: red">&#8216; &#8216; </span>+ <span style="COLOR: aqua">datename</span>(dd, <span style="COLOR: aqua">date</span>)</p>
<p style="MARGIN: 0px">   + <span style="COLOR: red">&#8216; &#8216; </span>+ <span style="COLOR: aqua">datename</span>(yy, <span style="COLOR: aqua">date</span>) [datename],</p>
<p style="MARGIN: 0px">   <span style="COLOR: red">&#8216;Fiscal &#8216; </span>+ <span style="COLOR: aqua">datename</span>(yy, <span style="COLOR: aqua">date</span>) fiscalyearname,</p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">datename</span>(mm, <span style="COLOR: aqua">date</span>) </p>
<p style="MARGIN: 0px">   + <span style="COLOR: red">&#8216;, &#8216; </span>+ <span style="COLOR: aqua">datename</span>(yy, <span style="COLOR: aqua">date</span>) fiscalmonthname,</p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">datepart</span>(<span style="COLOR: aqua">day</span>, <span style="COLOR: aqua">date</span>) <span style="COLOR: aqua">as </span>dayNumber,</p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">datepart</span>(<span style="COLOR: aqua">month</span>, <span style="COLOR: aqua">date</span>) <span style="COLOR: aqua">as </span>monthNumber,</p>
<p style="MARGIN: 0px">   <span style="COLOR: aqua">datepart</span>(<span style="COLOR: aqua">year</span>, <span style="COLOR: aqua">date</span>) <span style="COLOR: aqua">as </span>yearNumber</p>
<p style="MARGIN: 0px"><span style="COLOR: aqua">from</span></p>
<p style="MARGIN: 0px">   (</p>
<p style="MARGIN: 0px">      <span style="COLOR: aqua">select</span></p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">dateadd</span>(</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">day</span>, </p>
<p style="MARGIN: 0px">            n1.val * <span style="COLOR: yellow">10000 </span>+</p>
<p style="MARGIN: 0px">            n2.val * <span style="COLOR: yellow">1000 </span>+</p>
<p style="MARGIN: 0px">            n3.val * <span style="COLOR: yellow">100 </span>+</p>
<p style="MARGIN: 0px">            n4.val * <span style="COLOR: yellow">10 </span>+</p>
<p style="MARGIN: 0px">            n5.val,</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">cast</span>(<span style="COLOR: aqua">floor</span>(<span style="COLOR: aqua">cast</span>(mindate <span style="COLOR: aqua">as decimal</span>(<span style="COLOR: yellow">12</span>,<span style="COLOR: yellow">5</span>))) <span style="COLOR: aqua">as datetime</span>)) <span style="COLOR: aqua">date</span></p>
<p style="MARGIN: 0px">      <span style="COLOR: aqua">from</span></p>
<p style="MARGIN: 0px">        (</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">select </span><span style="COLOR: yellow">0 </span><span style="COLOR: aqua">as </span>val</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">1 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">2 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">3 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">4 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">5 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">6 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">7 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">8 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">9</span>) n1,</p>
<p style="MARGIN: 0px">            (</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">select </span><span style="COLOR: yellow">0 </span><span style="COLOR: aqua">as </span>val</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">1 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">2 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">3 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">4 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">5 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">6 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">7 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">8 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">9</span>) n2,</p>
<p style="MARGIN: 0px">            (</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">select </span><span style="COLOR: yellow">0 </span><span style="COLOR: aqua">as </span>val</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">1 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">2 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">3 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">4 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">5 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">6 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">7 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">8 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">9</span>) n3,</p>
<p style="MARGIN: 0px">            (</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">select </span><span style="COLOR: yellow">0 </span><span style="COLOR: aqua">as </span>val</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">1 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">2 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">3 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">4 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">5 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">6 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">7 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">8 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">9</span>) n4,</p>
<p style="MARGIN: 0px">            (</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">select </span><span style="COLOR: yellow">0 </span><span style="COLOR: aqua">as </span>val</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">1 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">2 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">3 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">4 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">5 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">6 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">7 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">8 </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all select </span><span style="COLOR: yellow">9</span>) n5,</p>
<p style="MARGIN: 0px">            (</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">select </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">min</span>(minDate) <span style="COLOR: aqua">as </span>minDate, </p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">max</span>(maxDate) <span style="COLOR: aqua">as </span>maxDate </p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">from </span></p>
<p style="MARGIN: 0px">            (<span style="COLOR: aqua">select </span></p>
<p style="MARGIN: 0px">               <span style="COLOR: aqua">min</span>(date) minDate, </p>
<p style="MARGIN: 0px">               <span style="COLOR: aqua">max</span>(date) maxdate</p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">from </span></p>
<p style="MARGIN: 0px">               &lt;Data table 1&gt;</p>
<p style="MARGIN: 0px"> </p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">union all</span></p>
<p style="MARGIN: 0px"> </p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">select </span></p>
<p style="MARGIN: 0px">               <span style="COLOR: aqua">min</span>(<span style="COLOR: aqua">date</span>), </p>
<p style="MARGIN: 0px">               <span style="COLOR: aqua">max</span>(<span style="COLOR: aqua">date</span>) </p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">from </span></p>
<p style="MARGIN: 0px">               &lt;Data table 2&gt;) dateVals</p>
<p style="MARGIN: 0px"> </p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">where </span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">year</span>(mindate) &gt;= <span style="COLOR: yellow">1980</span></p>
<p style="MARGIN: 0px">            <span style="COLOR: aqua">and year</span>(maxdate) &lt;= <span style="COLOR: aqua">dateadd</span>(<span style="COLOR: aqua">year</span>, <span style="COLOR: yellow">1</span>, <span style="COLOR: aqua">getdate</span>())</p>
<p style="MARGIN: 0px">            ) c</p>
<p style="MARGIN: 0px">      <span style="COLOR: aqua">where</span></p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">dateadd</span>(</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">day</span>, </p>
<p style="MARGIN: 0px">        n1.val * <span style="COLOR: yellow">10000 </span>+</p>
<p style="MARGIN: 0px">        n2.val * <span style="COLOR: yellow">1000 </span>+</p>
<p style="MARGIN: 0px">        n3.val * <span style="COLOR: yellow">100 </span>+</p>
<p style="MARGIN: 0px">        n4.val * <span style="COLOR: yellow">10 </span>+</p>
<p style="MARGIN: 0px">        n5.val,</p>
<p style="MARGIN: 0px">        <span style="COLOR: aqua">cast</span>(<span style="COLOR: aqua">floor</span>(<span style="COLOR: aqua">cast</span>(mindate <span style="COLOR: aqua">as decimal</span>(<span style="COLOR: yellow">12</span>,<span style="COLOR: yellow">5</span>))) <span style="COLOR: aqua">as datetime</span>)) &lt;= maxDate</p>
<p style="MARGIN: 0px">      ) dateVals</p>
</div>
<p><!--EndFragment--></p>
<g:plusone href="http://andrewdenhertog.com/sql-server/generating-list-of-dates/"></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://andrewdenhertog.com/sql-server/generating-list-of-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

