<?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>Eric Fickes &#187; calendar</title>
	<atom:link href="http://ericfickes.com/tag/calendar/feed/" rel="self" type="application/rss+xml" />
	<link>http://ericfickes.com</link>
	<description>Internets, Databases, Skateboards, Ice Hockeys, and Family</description>
	<lastBuildDate>Thu, 22 Jul 2010 22:45:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>I built a calendar in a tSQL SPROC</title>
		<link>http://ericfickes.com/2008/10/i-built-a-calendar-in-a-tsql-sproc/</link>
		<comments>http://ericfickes.com/2008/10/i-built-a-calendar-in-a-tsql-sproc/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 02:48:25 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[sql]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[sproc]]></category>
		<category><![CDATA[stored procedure]]></category>
		<category><![CDATA[table variables]]></category>
		<category><![CDATA[tsql]]></category>
		<category><![CDATA[tsql date functions]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=20</guid>
		<description><![CDATA[Here&#8217;s a blast from the past that I recently found in my archives. It&#8217;s a novelty stored procedure I wrote during my MS SQL 2000 DBA days. Back when I wrote this sproc, I was really big into writing calendar applications. I have written some sort of calendar application in almost every language I know, [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a blast from the past that I recently found in my archives.  It&#8217;s a novelty stored procedure I wrote during my MS SQL 2000 DBA days.<br />
Back when I wrote this sproc, I was really big into writing calendar applications.  I have written some sort of calendar application in<br />
almost every language I know, so writing one in tSql made sense to me.</p>
<p>While I never used this sproc in an application, or had any practical use for it, I still think it&#8217;s cool.  It&#8217;s primarily an excercise using<br />
tSql&#8217;s date functions, and my all time favorite feature of MS SQL 2000+, table variables.</p>
<p>If you use MSSQL 2000 or higher and don&#8217;t use table variables, I highly recommend looking into these.  In a nutshell, it&#8217;s a type of tSql variable<br />
that is a table.  You can select, insert, update, and delete the rows in this variable just like it&#8217;s a real table.  The lifespan of a table variable<br />
is the length of your connection to your db.  So if you have a table var #myTable in sprocA, as soon as sprocA completes execution, #myTable is gone.<br />
SprocB can&#8217;t access #myTable unless is specifically creates a new table var by this name.</p>
<p>So I wrote an article about this sproc for a database site years ago and I haven&#8217;t been able to find it again.  This was web1.0 days, so I&#8217;m sure the site<br />
is gone by now.  The good thing is I still have the sproc, and now you can to.</p>
<p>So here&#8217;s the info.  The sproc efCalendar accepts a month number and year number, and spits out two recordsets.</p>
<ol>
<li>Month, Year</li>
<li>Calendar view of that month</li>
</ol>
<p>Recordset 1 is two columns, month name, and year.</p>
<p>Recordset 2 is a calendar view of the specified month.  There is a column for each weekday, starting with Sunday and ending with Saturday.<br />
Then there is a row for each week in the specified month.</p>
<p>Here is what the results look like when run in Query Analyzer.</p>
<div id="attachment_19" class="wp-caption aligncenter" style="width: 509px"><a href="http://ericfickes.com/wp-content/uploads/2008/10/sproc-efcalendar.gif" rel="lightbox[20]"><img class="size-full wp-image-19" title="sproc-efcalendar" src="http://ericfickes.com/wp-content/uploads/2008/10/sproc-efcalendar.gif" alt="tSQL calendar sproc" width="499" height="370" /></a><p class="wp-caption-text">tSQL calendar sproc</p></div>
<p><a title="eric fickes loves mssql's table variables and sprocs" href="http://ericfickes.com/wp-content/uploads/2008/10/create_procedure_efcalendar.sql" target="download tsql calendar stored procedure">Download the efCalendar sproc here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2008/10/i-built-a-calendar-in-a-tsql-sproc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
