<?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>CFchimp &#187; SQL</title>
	<atom:link href="http://www.cfchimp.com/wordpress/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cfchimp.com/wordpress</link>
	<description>monkey love coldfusion</description>
	<lastBuildDate>Tue, 08 Jun 2010 13:40:56 +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>CF quickie: cfqueryparam with SQL&#8217;s LIKE operator</title>
		<link>http://www.cfchimp.com/wordpress/2009/12/cf-quickie-cfqueryparam-with-sqls-like-operator/</link>
		<comments>http://www.cfchimp.com/wordpress/2009/12/cf-quickie-cfqueryparam-with-sqls-like-operator/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 13:55:03 +0000</pubDate>
		<dc:creator>Chris Simmons</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.cfchimp.com/wordpress/?p=189</guid>
		<description><![CDATA[If you are using cfqueryparam to build a SQL statement from a search form and need to use the SQL&#8217;s LIKE operator here is how it&#8217;s done in the most basic way: &#60;cfquery name="qData" datasource="myDsn"&#62; SELECT DISTINCT last_name FROM person WHERE last_name LIKE &#60;cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.last_name#%"&#62; ORDER BY last_name &#60;/cfquery&#62; The magic is all in [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using cfqueryparam to build a SQL statement from a search form and need to use the SQL&#8217;s LIKE operator here is how it&#8217;s done in the most basic way:<br />
<code><br />
&lt;cfquery name="qData" datasource="myDsn"&gt;<br />
SELECT DISTINCT last_name<br />
FROM person<br />
WHERE last_name LIKE &lt;cfqueryparam cfsqltype="cf_sql_varchar" value="#FORM.last_name#%"&gt;<br />
ORDER BY last_name<br />
&lt;/cfquery&gt;<br />
</code><br />
The magic is all in the % sign at the end of the cfqueryparam value attribute.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cfchimp.com/wordpress/2009/12/cf-quickie-cfqueryparam-with-sqls-like-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion Dying&#8230; Again</title>
		<link>http://www.cfchimp.com/wordpress/2009/05/cf-dying-again/</link>
		<comments>http://www.cfchimp.com/wordpress/2009/05/cf-dying-again/#comments</comments>
		<pubDate>Mon, 18 May 2009 17:55:06 +0000</pubDate>
		<dc:creator>Chris Simmons</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Misc programming]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.cfchimp.com/wordpress/?p=145</guid>
		<description><![CDATA[So I took some database training with Global Knowledge last week.¬† My office paid for the training.¬† Apparently that &#8220;back end&#8221; training may be all for naught though since my front end programming language is on life support. Today&#8217;s Global Knowledge newsletter letter informed me (in very cheeky fashion) that ColdFusion is # 5 on [...]]]></description>
			<content:encoded><![CDATA[<p>So I took some database training with Global Knowledge last week.¬† My office paid for the training.¬† Apparently that &#8220;back end&#8221; training may be all for naught though since my front end programming language is on life support.</p>
<p>Today&#8217;s Global Knowledge newsletter letter informed me (in very cheeky fashion) that ColdFusion is # 5 on their &#8220;Dying Technology&#8221; list:</p>
<blockquote><p>&#8220;If any of these skills are your main expertise, perhaps it&#8217;s time to retrain.&#8221;</p>
<p>Here&#8217;s the whole article: <a href="http://www.globalknowledge.com/training/generic.asp?pageid=2347&amp;country=United+States">http://www.globalknowledge.com/training/generic.asp?pageid=2347&amp;country=United+States</a></p></blockquote>
<p>The notion of ColdFusion being dead has been debated into the ground so I&#8217;m not going to belabor it.</p>
<p>IMHO, ColdFusion is the best thing that ever happened to me from an IT standpoint.¬† If you want to get things done quickly, easily and reliably use it.¬† If you are thinking of ColdFusion along with COBOL, Netware, Flannel Shirts and &#8220;Grunge&#8221; Bands From Seattle, and¬† you might want step outside your house more.¬† It&#8217;s not the mid 90&#8242;s anymore.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cfchimp.com/wordpress/2009/05/cf-dying-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A few SQL queries</title>
		<link>http://www.cfchimp.com/wordpress/2008/05/a-few-sql-queries/</link>
		<comments>http://www.cfchimp.com/wordpress/2008/05/a-few-sql-queries/#comments</comments>
		<pubDate>Sat, 03 May 2008 01:48:48 +0000</pubDate>
		<dc:creator>Chris Simmons</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.cfchimp.com/wordpress/?p=49</guid>
		<description><![CDATA[I had to do some basic analysis of email addresses at my company the other day.¬† Here are a few useful SQL queries. Show 10 records with the most data in field &#8216;email&#8217; (10 longest email addresses) SELECT TOP 10 email, LEN(email) AS fieldLength FROM person ORDER BY fieldLength DESC Count all records with field [...]]]></description>
			<content:encoded><![CDATA[<p>I had to do some basic analysis of email addresses at my company the other day.¬† Here are a few useful SQL queries.</p>
<p>Show 10 records with the most data in field &#8216;email&#8217; (10 longest email addresses)<br />
<code><br />
SELECT TOP 10 email, LEN(email) AS fieldLength<br />
FROM person<br />
ORDER BY fieldLength DESC<br />
</code><br />
Count all records with field &#8216;email&#8217; over 20 chars<br />
<code><br />
SELECT COUNT(*) AS emailOver20<br />
FROM person<br />
WHERE LEN(email) &gt; 20<br />
</code><br />
Display the average length of data (in characters) of field &#8216;email&#8217;<br />
<code><br />
SELECT AVG(LEN(email)) AS emailAvgLength<br />
FROM person<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cfchimp.com/wordpress/2008/05/a-few-sql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CFGRID DateFormat</title>
		<link>http://www.cfchimp.com/wordpress/2008/04/cfgrid-dateformat/</link>
		<comments>http://www.cfchimp.com/wordpress/2008/04/cfgrid-dateformat/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 19:28:22 +0000</pubDate>
		<dc:creator>Chris Simmons</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.cfchimp.com/wordpress/?p=43</guid>
		<description><![CDATA[For some reason when you have a datetime field in a cfgrid column it displays in a long format like this: Nov 17 2006 01:00:00 Fig 1 (Below) A date displayed in cfgrid If we work a little SQL magic (using &#8220;CONVERT&#8221;) in the cfquery though we can do the formatting we want, which is: [...]]]></description>
			<content:encoded><![CDATA[<p>For some reason when you have a datetime field in a  cfgrid column it displays in a long format like this: Nov 17 2006 01:00:00</p>
<h6><strong> Fig 1 (Below) A date displayed in cfgrid</strong></h6>
<p><img src="http://www.cfchimp.com/wordpress/wp-content/uploads/2008/04/cfgrid_before.jpg" alt="CFGRID DateFormat Before" /></p>
<p>If we work a little SQL magic (using &#8220;CONVERT&#8221;) in the cfquery though we can do the formatting we want, which is: 11/17/2006.  Refer to the &#8220;styles&#8221; listed in Figure 3 to see what formatting is available.</p>
<p><strong>Coldfusion Query:</strong><br />
<code><cfquery name="q_record_note"><br />
SELECT note_id,note_text,<br />
CONVERT(varchar,note_date,101) as note_date<br />
FROM tbl_notes<br />
ORDER BY note_date<br />
</cfquery></code></p>
<h6><strong><strong>Fig 2 (Below) A date displayed in cfgrid after using CONVERT in cfquery</strong></strong></h6>
<p><img src="http://www.cfchimp.com/wordpress/wp-content/uploads/2008/04/cfgrid_after.jpg" alt="CFGRID DateFormat After" /></p>
<h6><strong><strong>Fig 3 (Below) A </strong></strong>helpful list of &#8220;styles&#8221; to use with the SQL CONVERT function</h6>
<table height="380" width="450">
<tr>
<td width="25%"><strong><font color="#003366">Style ID</font></strong></td>
<td width="75%"><strong><font color="#003366">Style Type</font></strong></td>
</tr>
<tr>
<td>0 or 100</td>
<td>mon dd yyyy hh:miAM (or PM)</td>
</tr>
<tr>
<td>101</td>
<td>mm/dd/yy</td>
</tr>
<tr>
<td>102</td>
<td>yy.mm.dd</td>
</tr>
<tr>
<td>103</td>
<td>dd/mm/yy</td>
</tr>
<tr>
<td>104</td>
<td>dd.mm.yy</td>
</tr>
<tr>
<td>105</td>
<td>dd-mm-yy</td>
</tr>
<tr>
<td>106</td>
<td>dd mon yy</td>
</tr>
<tr>
<td>107</td>
<td>Mon dd, yy</td>
</tr>
<tr>
<td>108</td>
<td>hh:mm:ss</td>
</tr>
<tr>
<td>9 or 109</td>
<td>mon dd yyyy hh:mi:ss:mmmAM (or PM)</td>
</tr>
<tr>
<td>110</td>
<td>mm-dd-yy</td>
</tr>
<tr>
<td>111</td>
<td>yy/mm/dd</td>
</tr>
<tr>
<td>112</td>
<td>yymmdd</td>
</tr>
<tr>
<td>13 or 113</td>
<td>dd mon yyyy hh:mm:ss:mmm(24h)</td>
</tr>
<tr>
<td>114</td>
<td>hh:mi:ss:mmm(24h)</td>
</tr>
<tr>
<td>20 or 120</td>
<td>yyyy-mm-dd hh:mi:ss(24h)</td>
</tr>
<tr>
<td>21 or 121</td>
<td>yyyy-mm-dd hh:mi:ss.mmm(24h)</td>
</tr>
<tr>
<td>126</td>
<td>yyyy-mm-dd Thh:mm:ss.mmm(no spaces)</td>
</tr>
<tr>
<td>130</td>
<td>dd mon yyyy hh:mi:ss:mmmAM</td>
</tr>
<tr>
<td>131</td>
<td>dd/mm/yy hh:mi:ss:mmmAM</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.cfchimp.com/wordpress/2008/04/cfgrid-dateformat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prepend existing data in SQL</title>
		<link>http://www.cfchimp.com/wordpress/2008/04/prepend-existing-data-in-sql/</link>
		<comments>http://www.cfchimp.com/wordpress/2008/04/prepend-existing-data-in-sql/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 21:31:38 +0000</pubDate>
		<dc:creator>Chris Simmons</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Web Dev]]></category>

		<guid isPermaLink="false">http://www.cfchimp.com/wordpress/?p=42</guid>
		<description><![CDATA[Disclaimer: This tip will probably be really basic for most SQL folks. The task: The company I work for has a web application that does some basic tracking of grants. The system feeding information to this application just had an across the board change to the numbering scheme of the grants. All grants must have [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Disclaimer:</strong> This tip will probably be really basic for most SQL folks.</p>
<p><strong>The task:</strong> The company I work for has a web application that does some basic tracking of grants.  The system feeding information to this application just had an across the board change to the numbering scheme of the grants.  All grants must have a prefix of &#8220;999-&#8221;.  Therefore, any grant not beginning with &#8220;999-&#8221; must be updated.  Example: a grant with the current number 8789966 needs to be 999-8789966.</p>
<p><strong>The solution:</strong> The SQL below does two things.  It updates all the grants to prepend the 999- prefix while also skipping any grants that are already correctly prefixed.</p>
<p><code><br />
UPDATE tbl_grants<br />
SET grant_no = '999-' + grant_no<br />
WHERE grant_no NOT LIKE '999-%'<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cfchimp.com/wordpress/2008/04/prepend-existing-data-in-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
