<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Computers are for People</title>
	
	<link>http://www.swegler.com/becky/blog</link>
	<description />
	<lastBuildDate>Fri, 20 Aug 2010 16:56:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/computersareforpeople" /><feedburner:info uri="computersareforpeople" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Higher Ed Web Symposium: Don Norman and Cory Ondrejka</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/0HQBZ-5saUY/</link>
		<comments>http://www.swegler.com/becky/blog/2010/07/26/higher-ed-web-symposium-don-norman-and-cory-ondrejka/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 17:24:46 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=328</guid>
		<description><![CDATA[Last week, the third annual Higher Ed Web Symposium was held at Wharton.  Despite being a speaker at the inaugural symposium in 2008, this was the first year I&#8217;ve been able to enjoy the event as an attendee. The keynote sessions were especially outstanding. Don Norman, a user interface legend and personal hero of mine, [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, the third annual <a title="2010 Wharton Higher Ed Web Symposium" href="http://web.wharton.upenn.edu/uiconf2010/">Higher Ed Web Symposium</a> was held at Wharton.  Despite being a speaker at the inaugural symposium in 2008, this was the first year I&#8217;ve been able to enjoy the event as an attendee.</p>
<p>The keynote sessions were especially outstanding.</p>
<p><a title="Don Norman (wikipedia)" href="http://en.wikipedia.org/wiki/Don_Norman"><strong>Don Norman</strong></a>, a user interface legend and personal hero of mine, spoke about Living With Complexity, also the title of his <a title="Don Norman: Living with Complexity" href="http://www.amazon.com/Living-Complexity-Donald-Norman/dp/0262014866">upcoming book</a>.  Basically,  he argues that complexity is good for us as long as it&#8217;s accompanied by good design.  Mr. Norman is a personal hero because so many principles from1988&#8242;s <a title="Don Norman: The Design of Everyday Things" href="http://www.amazon.com/Design-Everyday-Things-Donald-Norman/dp/0385267746"><em>The Design of Everyday Things</em></a> still hold true.  Also, because his work is a comfort whenever I&#8217;m confused by an elevator or walk into a glass door.</p>
<p>Watch Don Norman&#8217;s talk <a title="Wharton Web Symposium Day 1 keynote: Don Norman" href="http://wharton.mediasite.com/mediasite/SilverlightPlayer/Default.aspx?peid=3ddb621cd0774e80a1b619dc9b9023411d">here</a>.</p>
<p><a title="Cory Ondrejka (wikipedia)" href="http://en.wikipedia.org/wiki/Cory_Ondrejka"><strong>Cory Ondrejka</strong></a>, a Second Life co-founder, blew away the audience with his Angry Dinosaurs talk on Day Two.  In 75 minutes and 300+ slides, Cory talked about institutional incompetence and hacks for accelerating change by citing examples from the music industry, the newspaper business, and the 19th century US Navy.  A fast-paced, fascinating talk.  I&#8217;ve already watched it twice.</p>
<p>Watch Cory Ondrejka&#8217;s talk <a title="Wharton Web Symposium Day 2 keynote: Cory Ondrejka" href="http://wharton.mediasite.com/mediasite/SilverlightPlayer/Default.aspx?peid=96088f6d4bff476899188ac8d65f74581d">here</a>.  It has implications for everyone in an organization, not just designers and technologists.</p>
<p>To all of my colleagues who organized the Higher Ed Web symposium and its virtual counterpart, congratulations and thank you!</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2010/07/26/higher-ed-web-symposium-don-norman-and-cory-ondrejka/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2010/07/26/higher-ed-web-symposium-don-norman-and-cory-ondrejka/</feedburner:origLink></item>
		<item>
		<title>Van Pelt’s mobile landing page</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/ISz7Q0Mhvew/</link>
		<comments>http://www.swegler.com/becky/blog/2010/06/09/van-pelts-mobile-landing-page/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 02:26:29 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=296</guid>
		<description><![CDATA[I&#8217;m currently working on a project to upgrade the mobile version of Wharton Computing&#8217;s student portal. As we searched for ideas, my colleague Erin stumbled across the Van Pelt Library&#8217;s new mobile site. Like us, the library hasn&#8217;t yet gone native (though we are planning a app store adventure in the near future). Instead, they [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a project to upgrade the mobile version of Wharton Computing&#8217;s student portal.  As we searched for ideas, my colleague <a title="Erin Murphy" href="https://blogs.wharton.upenn.edu/staff/remurphy/">Erin</a> stumbled across the Van Pelt Library&#8217;s new <a title="University of Pennsylvania library mobile website" href="http://www.library.upenn.edu/m/">mobile site</a>.</p>
<p>Like us, the library hasn&#8217;t yet gone native (though we are planning a app store adventure in the near future).  Instead, they stuck with the web but incorporated iPhone-like icons.</p>
<p>Take a close look at the Video Search icon. Although the cat is meant to represent VCat (Penn Library Video Catalog),  it doubles as a brilliant acknowledgment that online videos are synonymous with cute kitties.</p>
<p>I love it, and I love the underlying sense of fun.  Stay crazy, you library icon designers!</p>
<p><a href="http://www.swegler.com/becky/blog/wp-content/uploads/2010/07/van-pelt-icons.jpg" rel="lightbox[296]" title="van pelt icons"><img class="alignnone size-full wp-image-321" title="van pelt icons" src="http://www.swegler.com/becky/blog/wp-content/uploads/2010/07/van-pelt-icons.jpg" alt="icons on Van Pelt Library's mobile website" width="320" height="480" /></a></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2010/06/09/van-pelts-mobile-landing-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2010/06/09/van-pelts-mobile-landing-page/</feedburner:origLink></item>
		<item>
		<title>Regular Expression for dollar amount validation</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/PflUV46WI8w/</link>
		<comments>http://www.swegler.com/becky/blog/2009/12/16/regular-expression-for-dollar-amount-validation/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 17:54:47 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=258</guid>
		<description><![CDATA[A regular expression to validate dollar amounts.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m finishing up a small project that required validating dollar amounts on web-based form fields, and luckily I was using the wonderful <a href="http://docs.jquery.com/Plugins/Validation" title="jQuery validation plugin">Validation jQuery plugin</a>. </p>
<p>Although this plugin doesn&#8217;t come with an out-of-the-box dollar validator method, it&#8217;s very easy to add your own.  The trick was to find an appropriate regular expression.  Although Google turned up several regex examples for validating dollar inputs, none met my exact criteria (the ultimate goal being to provide users with the greatest amount of data-entry leeway):</p>
<ul>
<li>Allow the user to type in the <em>$</em> (or not)</li>
<li>Allow amounts less than one dollar (<em>i.e.</em>, 0 &#8211; .99)</li>
<li>Allow an optional one or two decimal places</li>
<li>No negative dollar amounts</li>
</ul>
<p>So this is what I came up with, and it seems to be working.  Two notes: (a) this expression allows inappropriate commas, but I&#8217;m stripping those out during the server-side validations, and (b) it is used in conjunction with the <em>max()</em> validator function to ensure the user doesn&#8217;t enter anything that could blow up a SQL Server money column:<br />
<code><br />
^\$?[0-9][0-9\,]*(\.\d{1,2})?$|^\$?[\.]([\d][\d]?)$<br />
</code></p>
<p>The final jQUery validator method:<br />
<code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//custom validator for money fields</span>
jQuery.<span style="color: #660066;">validator</span>.<span style="color: #660066;">addMethod</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;money&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">,</span> element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">optional</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009966; font-style: italic;">/^\$?[0-9][0-9\,]*(\.\d{1,2})?$|^\$?[\.]([\d][\d]?)$/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Please provide a valid dollar amount (up to 2 decimal places)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p></code></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/12/16/regular-expression-for-dollar-amount-validation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/12/16/regular-expression-for-dollar-amount-validation/</feedburner:origLink></item>
		<item>
		<title>Swiz framework for Flex</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/ROljvyvBDYw/</link>
		<comments>http://www.swegler.com/becky/blog/2009/11/21/swiz-framework-for-flex/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 23:45:04 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[swiz]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=277</guid>
		<description><![CDATA[Code for a sample Flex application using the Swiz framework.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.swegler.com/becky/blog/wp-content/uploads/2010/11/swiz.png" rel="lightbox[277]" title="swiz"><img class="alignnone size-full wp-image-279" title="swiz" src="http://www.swegler.com/becky/blog/wp-content/uploads/2010/11/swiz.png" alt="Swiz sample application" width="420" height="239" /></a></p>
<p><a title="Swiz sample app code" href="http://swegler.com/becky/code/swiz/srcview/">View the sample app code</a>.</p>
<p>Some folks in Wharton Computing, namely <a title="Nathan's blog" href="http://www.mischefamily.com/nathan/">Nathan</a> and <a title="Adam's blog" href="http://fusiongrokker.com/">Adam</a>, have had positive experiences using the <a title="Swizframework.org" href="http://swizframework.org/">Swiz framework</a> for Flex applications.</p>
<p>I haven’t used Flex frameworks in the past because a) I was still learning Flex and wasn’t ready to throw a framework into the mix and b) the only real option was Cairngorm, which seemed like complete overkill.</p>
<p>Now that I’m more comfortable with Flex and understand some of its limitations, however, I can endorse Swiz.</p>
<p>Why do I like Swiz?  Because it doesn’t impose a strict structure and because it solves actual problems.  Even if you don’t care about separating your model from your views or abstracting service calls, Swiz is worth investigating for these reasons:</p>
<p>Event Handling:  You can dispatch events at will and add the corresponding event listeners where required.  You don’t have to worry about the fact the Flex events bubble up and not down—Swiz just takes care of it.</p>
<p>Command Chains:  It’s often the case that Flex remote object calls need to occur in a particular sequence or that a series of remote object calls needs to complete before moving on to the next piece of code.  The logic required to ensure everything happens in the right order can get messy and only gets worse over time.  Swiz allows you to define a series of commands (called a CommandChain) and execute them together (sequentially or in parallel).</p>
<p>The Swiz Google code page and the Swiz Framework site have some instructions for getting started with Swiz.  The code samples are piecemeal and outdated, however, so I created a small project that demonstrates basic Swiz functions.  It’s a pretty silly app, but I created it so the Wharton Computing developer community could reference some well-commented code that works in our environment.</p>
<p>Because the back-end services are written in ColdFusion and it’s not especially practical to invest in CF hosting just to demo this, what you see here is just a screenshot* and <a title="Swiz sample app code" href="http://swegler.com/becky/code/swiz/srcview/">the code</a>.</p>
<p>Thanks to Nathan, who unknowingly provided some of the code for this sample app.</p>
<p>*Note the Phillies colors on the demo app. The default Flex theme is not meant for public viewing.  Ever.  <a title="Flex style explorer" href="http://examples.adobe.com/flex3/consulting/styleexplorer/Flex3StyleExplorer.html#">It’s not hard</a> to spiff up your apps a bit!</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/11/21/swiz-framework-for-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/11/21/swiz-framework-for-flex/</feedburner:origLink></item>
		<item>
		<title>Beware the change scripts created by SQL Server Management Studio</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/PPlXlfe0fC8/</link>
		<comments>http://www.swegler.com/becky/blog/2009/10/27/beware-the-change-scripts-created-by-sql-server-management-studio/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 02:20:55 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tsql]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=178</guid>
		<description><![CDATA[Don’t rely on these SQL Server Management Studio-generated change scripts for any serious work, and definitely don't use them as a model for how to write robust T-SQL.]]></description>
			<content:encoded><![CDATA[<p>Part of my job is moonlighting as a SQL Server database admin, so a co-worker recently asked me to run a script against a production table.  The task was simple: add a few new columns and create some indexes.  He had generated the script by using SQL Server 2008 Management Studio&#8217;s (SSMS) Generate Change Script function.</p>
<p>Although the general sequence of steps in the generated script made sense, I have some complaints about the SSMS output.  Here’s a very simple recreation of the scenario.</p>
<p>Consider a table with two columns.  One is a primary key, and one has a default constraint:<br />
<code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> phillies <span style="color: #66cc66;">&#40;</span>
   phils_id INT IDENTITY<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">,</span>  phils_year CHAR<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
   CONSTRAINT df_phillies_year <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2008</span><span style="color: #66cc66;">&#41;</span> 
<span style="color: #66cc66;">,</span>  CONSTRAINT pk_phils_id 
      <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> CLUSTERED <span style="color: #66cc66;">&#40;</span>phils_id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p></code></p>
<p>Using the SSMS table design view to add two columns to the phillies table and saving the change script results in the following code:<br />
<code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">BEGIN TRANSACTION
GO
<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> dbo<span style="color: #66cc66;">.</span>phillies
   <span style="color: #993333; font-weight: bold;">DROP</span> CONSTRAINT df_phillies_year
GO
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> dbo<span style="color: #66cc66;">.</span>Tmp_phillies <span style="color: #66cc66;">&#40;</span>
   phils_id int <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> IDENTITY <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   phils_year char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
   division_champ_flag bit <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
   national_champ_flag bit <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #66cc66;">&#41;</span>  <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">PRIMARY</span><span style="color: #66cc66;">&#93;</span>
GO
<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> dbo<span style="color: #66cc66;">.</span>Tmp_phillies 
   <span style="color: #993333; font-weight: bold;">ADD</span> CONSTRAINT
   df_phillies_year <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2008</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">FOR</span> phils_year
GO
<span style="color: #993333; font-weight: bold;">SET</span> IDENTITY_INSERT dbo<span style="color: #66cc66;">.</span>Tmp_phillies <span style="color: #993333; font-weight: bold;">ON</span>
GO
<span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">EXISTS</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> dbo<span style="color: #66cc66;">.</span>phillies<span style="color: #66cc66;">&#41;</span>
   EXEC<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'INSERT INTO dbo.Tmp_phillies 
      (phils_id, phils_year)
   SELECT phils_id, phils_year 
   FROM dbo.phillies 
   WITH (HOLDLOCK TABLOCKX)'</span><span style="color: #66cc66;">&#41;</span>
GO
<span style="color: #993333; font-weight: bold;">SET</span> IDENTITY_INSERT dbo<span style="color: #66cc66;">.</span>Tmp_phillies OFF
GO
<span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> dbo<span style="color: #66cc66;">.</span>phillies
GO
EXECUTE sp_rename 
   N<span style="color: #ff0000;">'dbo.Tmp_phillies'</span><span style="color: #66cc66;">,</span> N<span style="color: #ff0000;">'phillies'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'OBJECT'</span> 
GO
<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> dbo<span style="color: #66cc66;">.</span>phillies 
   <span style="color: #993333; font-weight: bold;">ADD</span> CONSTRAINT
   pk_phils_id <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> CLUSTERED 
   <span style="color: #66cc66;">&#40;</span>phils_id<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">PRIMARY</span><span style="color: #66cc66;">&#93;</span>
GO
COMMIT</pre></td></tr></table></div>

<p></code></p>
<p>This script contains BEGIN TRANSACTION and COMMIT TRANSACTION statements but doesn’t accompany them with any kind of error handling.  So if you run it as-is and encounter an error, nothing gets rolled back.  </p>
<p>Any error handling that you might add, however, is thwarted by the fact that the script&#8217;s statements are contained in individual batches (<em>i.e.</em>, separated by <a href="http://msdn.microsoft.com/en-us/library/ms188037.aspx" title="GO statement">GO statements</a>).</p>
<p>Say you individually check each statement for errors and issue a rollback/return if something goes awry.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;">BEGIN TRANSACTION
GO
<span style="color: #66cc66;">&#91;</span>snip<span style="color: #66cc66;">&#93;</span>
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> dbo<span style="color: #66cc66;">.</span>Tmp_phillies <span style="color: #66cc66;">&#40;</span>
   phils_id int <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> IDENTITY <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
   phils_year char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
   division_champ_flag bit <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
   national_champ_flag bit <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #66cc66;">&#41;</span>  <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">PRIMARY</span><span style="color: #66cc66;">&#93;</span>
GO
<span style="color: #66cc66;">&#91;</span>snip<span style="color: #66cc66;">&#93;</span>
<span style="color: #808080; font-style: italic;">-- throw an error</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #cc66cc;">23</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">0</span>
<span style="color: #993333; font-weight: bold;">IF</span> @@ERROR <span style="color: #66cc66;">&lt;&gt;</span> <span style="color: #cc66cc;">0</span>
BEGIN
   PRINT <span style="color: #ff0000;">'error!'</span>
   ROLLBACK TRANSACTION
   <span style="color: #993333; font-weight: bold;">RETURN</span>
END
<span style="color: #66cc66;">&#91;</span>snip<span style="color: #66cc66;">&#93;</span>
GO
<span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">TABLE</span> dbo<span style="color: #66cc66;">.</span>phillies</pre></td></tr></table></div>

<p>In this scenario, changes that occurred prior to the error will be rolled back.  However, although the RETURN statement exits the current batch, subsequent batches (for example, the one that deletes your table) will execute.</p>
<p>A TRY/CATCH block is another potential error-handling method, but <a href="http://msdn.microsoft.com/en-us/library/ms175976(SQL.90).aspx" title="TSQL TRY/CATCH blocks">TRY/CATCH blocks can’t span multiple batches</a>.</p>
<p>So what&#8217;s with the batch-happy SSMS? In older versions of SQL it might have been necessary to separate a CREATE TABLE and subsequent ALTER TABLE statements into separate batches (I haven&#8217;t tested this).  But SQL 2005 and 2008 provide <a href="http://msdn.microsoft.com/en-us/library/ms175502(SQL.90).aspx" title="statement level recompilation">statement-level recompilation</a>, so the multitude of batches is not necessary.</p>
<p>When I tested a &#8220;GO-less&#8221; version of the script, it worked swimmingly.  It&#8217;s understandable that SSMS can&#8217;t generate the error-handling, but if it would reduce the scripts&#8217; number of batches to the minimum required, it would be easier to add the error handling yourself.</p>
<p>Conclusion: don’t rely on these SQL Server Management Studio-generated change scripts for any serious work, and definitely don&#8217;t use them as a model for how to write robust T-SQL.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/10/27/beware-the-change-scripts-created-by-sql-server-management-studio/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/10/27/beware-the-change-scripts-created-by-sql-server-management-studio/</feedburner:origLink></item>
		<item>
		<title>Database Design Presentation</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/QKCiw7-WAgY/</link>
		<comments>http://www.swegler.com/becky/blog/2009/10/02/database-design-presentation/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 03:17:49 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=147</guid>
		<description><![CDATA[The slides from a database design presentation given by myself and Tim Allen.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.swegler.com/becky/blog/wp-content/uploads/2009/10/normalization.jpg" rel="lightbox[147]" title="normalization"><img class="size-medium wp-image-164 alignnone" title="normalization" src="http://www.swegler.com/becky/blog/wp-content/uploads/2009/10/normalization-300x224.jpg" alt="database normalization" width="300" height="224" /></a></p>
<p>I&#8217;m extremely happy to work in an organization with an uber-smart and supportive group of developers.  Once a month we meet for a lunchtime &#8220;tech talk&#8221; presentation on a topic chosen via <a title="Google Moderator" href="http://moderator.appspot.com/">Google Moderator</a>.</p>
<p>This month, <a title="Tim Allen" href="http://www.peregrinesalon.com/">Tim Allen</a> and I collaborated and spoke about database design.  Working with Tim to research and organize the material was a blast, and even though we put silly pictures of ourselves on the slides, I&#8217;m posting them.</p>
<p>We focused most closely on normalization and indexing, with a few of our other best practices thrown in the mix.  The concepts should be applicable to any RDBMS, but the details are specific to MS SQL Server, the database used in most of the organization&#8217;s applications.</p>
<p><a title="database design presentation" href="http://www.swegler.com/becky/blog/wp-content/uploads/2009/10/wcit-techtalk-database-design.pdf">wcit-techtalk-database-design</a></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/10/02/database-design-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/10/02/database-design-presentation/</feedburner:origLink></item>
		<item>
		<title>Hypnotic B-Tree Video</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/RpmOOoGj1mM/</link>
		<comments>http://www.swegler.com/becky/blog/2009/09/30/hypnotic-b-tree-video/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 16:32:16 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=136</guid>
		<description><![CDATA[A hypnotic YouTube video that demonstrates inserts into a b-tree data structure.]]></description>
			<content:encoded><![CDATA[<p>While preparing a database design presentation with my co-worker <a href="http://www.peregrinesalon.com/">Tim</a>, I discovered this <a href="http://www.youtube.com/watch?v=coRJrcIYbF4" title="hypnotic b-tree video">hypnotic video</a> demonstrating inserts into a b-tree data structure.  For some reason, the music compels me to leave the cubicle and pay a visit to <a href="http://www.yelp.com/biz/ramis-philadelphia">Rami&#8217;s falafel truck</a>.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/coRJrcIYbF4&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/coRJrcIYbF4&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/09/30/hypnotic-b-tree-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/09/30/hypnotic-b-tree-video/</feedburner:origLink></item>
		<item>
		<title>Daniel Pink and the Evolution of Learning</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/3v9Efpe_IDk/</link>
		<comments>http://www.swegler.com/becky/blog/2009/06/01/daniel-pink-and-the-evolution-of-learning/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 19:22:31 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Learning & Tech]]></category>
		<category><![CDATA["daniel pink"]]></category>
		<category><![CDATA[a whole new mind]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=129</guid>
		<description><![CDATA[Re-cap of the 2009 Wharton Evolution of Learning Symposium.  Video of Daniel Pink's keynote address and the subsequent panel discussion with Chris Lehmann, Doug Lynch, and Karl Ulrich.]]></description>
			<content:encoded><![CDATA[<p>On May 13th, 2009, Wharton Computing sponsored the inaugural <a title="Wharton Evolution of Learning Symposium" href="http://www.wharton.upenn.edu/evolvelearning/">Evolution of Learning Symposium</a>.  I&#8217;m proud to have served on the planning committee for this successful event that featured a keynote by <a title="Daniel Pink" href="http://www.wharton.upenn.edu/evolvelearning/speakers.cfm#pink">Daniel Pink</a> and a panel discussion by some great educators:</p>
<ul>
<li><a title="Chris Lehmann" href="http://www.wharton.upenn.edu/evolvelearning/speakers.cfm#lehmann">Chris Lehmann</a>, founding principal of Philadelphia&#8217;s Science Leadership Academy</li>
<li><a title="Doug Lynch" href="http://www.wharton.upenn.edu/evolvelearning/speakers.cfm#lynch">Doug Lynch</a>, Vice Dean of Penn&#8217;s Graduate School of Education</li>
<li><a title="Karl Ulrich" href="http://www.wharton.upenn.edu/evolvelearning/speakers.cfm#ulrich">Karl T. Ulrich</a>, professor of Entrepreneurship and e-Commerce at the Wharton School</li>
</ul>
<p>It was pretty amazing to sit in a room and listen to these brains hash out some of the issues facing higher ed (and by extension, K-12) right now.  A complete recap, including speaker videos, photos, and a copy of the obligatory live Tweets* are available <a title="Wharton 2009 Evolution of Learning recap" href="http://www.wharton.upenn.edu/evolvelearning/recap.cfm">here</a>.</p>
<p>*For the record,<a title="Pay Attention!" href="http://www.swegler.com/becky/blog/?p=91"> still not a fan of the live Tweeting</a>.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/06/01/daniel-pink-and-the-evolution-of-learning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/06/01/daniel-pink-and-the-evolution-of-learning/</feedburner:origLink></item>
		<item>
		<title>Lesson From the Jury Box</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/rw39e9mvvU8/</link>
		<comments>http://www.swegler.com/becky/blog/2009/03/13/jury-duty-deep-thought-1-pay-attention/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 16:40:00 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[attention]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[social media]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=91</guid>
		<description><![CDATA[Put down the phone, the netbook, the notebook and pay attention.]]></description>
			<content:encoded><![CDATA[<p>Serving as an alternate juror is one of life’s more frustrating exercises.  It’s all the inconvenience of attending the trial and none of the decision making.  In terms of actual hours worked, however, it&#8217;s an easy job:  arrive at 9:30, start working at 10 or 10:30, take a two hour lunch, and leave by 4:30. This schedule leaves plenty of room for deep thoughts. I even broke a longstanding policy and bought a pretentious Moleskin notebook because I wanted my deep thoughts to be important and stylish.</p>
<p>Deep thought number 1:  what do we miss by not paying attention?<br />
Our judge instructed us not to take notes—we had to sit in the jury box without the aid of external mnemonic devices, which seemed like an impediment that could well lead to a travesty of justice.</p>
<p>I found the opposite to be true, though. When was the last time you sat in a room without phones, newspapers, iPods, or conversations and just actively listened? It’s the freedom to find the truth by not only listening but by studying clues like body language, demeanor, and facial expressions, which you can’t do when your head is buried in a notebook. There’s a place for conversations, questions, and notes, but it’s during deliberations, when twelve people bring their individual observations to the jury room and render a verdict.</p>
<p>Outside of the courtroom, we spend a lot of time and money to go places and do things, only to cheat ourselves by not paying attention.  It’s become more important to broadcast and perfectly capture our trips, conferences, and nights out than to live them. What contextual information do we miss when live-tweeting a keynote address?  How can we form mature, thoughtful, and independent judgments in a world of chatter and soundbytes? Information might be free, but knowledge and wisdom require a price, part of which is knowing when to listen.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/03/13/jury-duty-deep-thought-1-pay-attention/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/03/13/jury-duty-deep-thought-1-pay-attention/</feedburner:origLink></item>
		<item>
		<title>SQL Server operand type clash!</title>
		<link>http://feedproxy.google.com/~r/computersareforpeople/~3/RSXSWy82Upg/</link>
		<comments>http://www.swegler.com/becky/blog/2009/02/06/sql-server-operand-type-clash/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 22:00:03 +0000</pubDate>
		<dc:creator>bsweger</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tsql]]></category>

		<guid isPermaLink="false">http://www.swegler.com/becky/blog/?p=31</guid>
		<description><![CDATA[What can happen when components of a T-SQL CASE statement return different data types.]]></description>
			<content:encoded><![CDATA[<p><strong>Note:  This article was originally published to the <a title="Wharton Computing Developer Center" href="http://seven-dev.wharton.upenn.edu/devcenter/index.cfm?method=read&amp;entry_id=380">Wharton Computing Developer Center</a>.</strong></p>
<p>Yesterday a fellow developer hit a strange SQL error and determined that the culprit was a T-SQL CASE statement used in his ORDER BY clause.<br />
<code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span>
CASE
WHEN UPPER<span style="color: #66cc66;">&#40;</span>@orderBy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'GROUPMESSAGEID'</span> THEN groupMessageID
WHEN UPPER<span style="color: #66cc66;">&#40;</span>@orderBy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'GAMEID'</span> THEN gameID
WHEN UPPER<span style="color: #66cc66;">&#40;</span>@orderBy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'GROUPID'</span> THEN groupID
WHEN UPPER<span style="color: #66cc66;">&#40;</span>@orderBy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'MESSAGEID'</span> THEN messageID
WHEN UPPER<span style="color: #66cc66;">&#40;</span>@orderBy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'ROUNDSENT'</span> THEN roundSent
WHEN UPPER<span style="color: #66cc66;">&#40;</span>@orderBy<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'SENTON'</span> THEN sentOn
ELSE groupMessageID
END</pre></td></tr></table></div>

<p></code></p>
<p>This code results in the following message:<br />
Operand type clash: uniqueidentifier is incompatible with datetime</p>
<p>After some digging around, we found the underlying cause of the error:  the case statement return values have different data types.  In some cases, returning different data types will behave as expected.  However, mixing numeric and character data causes problems.</p>
<p>In the statement above, gameId, groupID, roundSent, and groupMessageID are integers, sentOn is a datetime, and messageID is a uniqueidentifier.  Because the data type precedence pecking order in this case is datetime, int, and then uniqueidentifier, SQL choose datetime as the return type. Uniqueidentifiers cannot be converted to datetimes, hence the error message.</p>
<p>It all became clear after reading <a href="http://blogs.lessthandot.com/index.php/DataMgmt/DBProgramming/MSSQLServer/sql-server-case-when-data-type-problems">this article by George Mastros</a>.  Thank you to George.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://www.swegler.com/becky/blog/2009/02/06/sql-server-operand-type-clash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.swegler.com/becky/blog/2009/02/06/sql-server-operand-type-clash/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.410 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-08-20 09:57:11 -->
