<?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>Ricardo Parente&#039;s Blog &#187; Database</title>
	<atom:link href="http://ricardo.parente.us/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://ricardo.parente.us</link>
	<description>ColdFusion Developers Network</description>
	<lastBuildDate>Fri, 10 Feb 2012 17:13:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>ColdFusion MeetUp: One DAO to Rule Them All…!!, with Wes Byrd</title>
		<link>http://ricardo.parente.us/2011/05/coldfusion-meetup-one-dao-to-rule-them-all%e2%80%a6-with-wes-byrd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coldfusion-meetup-one-dao-to-rule-them-all%25e2%2580%25a6-with-wes-byrd</link>
		<comments>http://ricardo.parente.us/2011/05/coldfusion-meetup-one-dao-to-rule-them-all%e2%80%a6-with-wes-byrd/#comments</comments>
		<pubDate>Mon, 30 May 2011 15:16:39 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MeetUp]]></category>
		<category><![CDATA[Seminars]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[DAO]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=6036</guid>
		<description><![CDATA[Announcing a new Meetup for The Online ColdFusion Meetup! What: &#8220;One DAO to Rule Them All…!!&#8221;, with Wes Byrd Our 6pm (US ET) talk on Thursday June 2 will be &#8220;One DAO to Rule Them All…!!&#8221;, with Wes Byrd. TOPIC DESCRIPTION: (provided by the speaker) The DADAO is a single CFC that will act as a Data [...]]]></description>
			<content:encoded><![CDATA[<p>Announcing a new Meetup for The Online ColdFusion Meetup!</p>
<p><strong>What</strong>: <a title="http://www.meetup.com/coldfusionmeetup/events/20203111/" href="http://www.meetup.com/coldfusionmeetup/events/20203111/" target="_blank">&#8220;One DAO to Rule Them All…!!&#8221;, with Wes Byrd </a></p>
<p>Our 6pm <strong>(US ET)</strong> talk on Thursday June 2 will be &#8220;One DAO to Rule Them All…!!&#8221;, with Wes Byrd.</p>
<p><strong>TOPIC DESCRIPTION:</strong> (provided by the speaker)</p>
<p>The DADAO is a single CFC that will act as a Data Access Object (DAO) to any table in your database offering one place to Create, Read, Update and Delete (CRUD) data from any table. Never create another DAO again! Never maintain your DAO’s again! Never write SQL in your code again! It changes when your database changes. It supports any database type (that ColdFusion will access via a configured datasource).</p>
<p>In this session, we will see some real world examples of this handy tool in action and have some general discussion on Data Access Objects in general.</p>
<p><strong>MEETING URL: <a title="http://experts.acrobat.com/cfmeetup/" href="http://experts.acrobat.com/cfmeetup/" target="_blank">http://experts.acrobat.com/cfmeetup/</a></strong></p>
<p><strong>DURATION:</strong> Approx. 1 hour</p>
<p><strong>RECORDING: All meetings are recorded.</strong> The URL will be posted after meeting at <strong><a title="http://recordings.coldfusionmeetup.com/" href="http://recordings.coldfusionmeetup.com/" target="_blank">recordings.coldfusionmeetup.com</a></strong></p>
<p><strong><span id="more-6036"></span><br />
</strong></p>
<p><strong>SPEAKER:</strong> (provided by the speaker)</p>
<p>Wes Byrd has been developing in ColdFusion sense 1998 and is currently the user group manager of Central Georgia Cold Fusion User Group.  His current project/passion is Upward Web, a web development services Ministry that provides website development and hosting for Christian based ministries.  <a title="http://www.facebook.com/upwardweb" href="http://www.facebook.com/upwardweb" target="_blank">http://www.facebook.com/upwardweb</a></p>
<p><strong>WHEN:</strong> Thurs. June 2, 6:00pm <strong>US ET (UTC/GMT-4)</strong></p>
<p><strong>What time is that for you?</strong> The following link shows <strong>[<a title="http://permatime.com/US/Eastern/2011-06-2/18:00/" href="http://permatime.com/US/Eastern/2011-06-2/18:00/" target="_blank">what the time would be for you</a>]</strong>. Here&#8217;s <strong>[<a title="http://www.timeanddate.com/worldclock/fixedtime.html?year=2011&amp;month=06&amp;day=2&amp;hour=18&amp;min=00&amp;sec=0&amp;p1=25" href="http://www.timeanddate.com/worldclock/fixedtime.html?year=2011&amp;month=06&amp;day=2&amp;hour=18&amp;min=00&amp;sec=0&amp;p1=25" target="_blank">another option</a>]</strong> that shows the time as US ET, and lets you choose your city from the list offered to see what time that is in your own timezone.</p>
<p><strong>RECORDING:</strong> As always, the meeting will be recorded, and the recording URL will be posted after the meeting at <a title="http://recordings.coldfusionmeetup.com/" href="http://recordings.coldfusionmeetup.com/" target="_blank">http://recordings.coldfusionmeetup.com</a>.</p>
<p><strong>DOWNLOADABLE RECORDINGS:</strong><br />
In addition to the streaming recording posted immediately after the meeting, we now also post downloadable recordings (FLV, MP3, MP4, and WMV) usually within a few days after the meeting, also offered as a link from the recordings page.</p>
<p><strong>LOGGING IN:</strong> When you login to the Connect room (the<a title="http://experts.acrobat.com/cfmeetup" href="http://experts.acrobat.com/cfmeetup" target="_blank"> experts.acrobat.com/cfmeetup</a> link above) to view the meeting, PLEASE USE THE &#8220;LOGIN AS GUEST&#8221; option, and USE YOUR NAME, but do NOT attempt to use your <a title="http://meetup.com/" href="http://meetup.com/" target="_blank">meetup.com</a> username/password or any Connect account. Just sign in as a guest.</p>
<p><strong>RSVP, but only if coming:</strong> We do appreciate folks RSVPing if they plan to come (using the link on this email or at the meetup site), though it&#8217;s not mandatory and it&#8217;s not a commitment. But there&#8217;s<strong>no need to RSVP if you can&#8217;t make it</strong> let alone explain why you can&#8217;t. With over 2,500 members, no worries. <img src='http://ricardo.parente.us/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>FEEDBACK/MEETING DISCUSSION</strong>: Members will receive an email after the meeting or can click a link on the event page to offer. Note also the meeting-specific discussion area there at the bottom, in addition to the one-chance feedback feature on the right. Feel free to engage in discussions about the meeting topic.</p>
<p><strong>ADD THIS TO YOUR CALENDAR:</strong> Want to add this event to your own personal calendar? After logging in here, you&#8217;ll see an option at the top of the event page, just below the event title,  saying, &#8220;Add to my calendar&#8221;, which offers calendar downloads for Outlook, iCal, Google, and Yahoo calendars. (Note that the calendar entry created will show the event taking 2 hours. That&#8217;s a default that <a title="http://meetup.com/" href="http://meetup.com/" target="_blank">meetup.com</a> has chosen, which I can&#8217;t change. The meetings are generally about an hour, though often go as much as 30-45 minutes longer with Q&amp;A and chat.)</p>
<p><strong><a title="http://www.meetup.com/coldfusionmeetup/events/20203111/" href="http://www.meetup.com/coldfusionmeetup/events/20203111/" target="_blank">Check it out!</a></strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2011/05/coldfusion-meetup-one-dao-to-rule-them-all%e2%80%a6-with-wes-byrd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSAS: Forecast Video Tutorial</title>
		<link>http://ricardo.parente.us/2010/12/ssas-forecast-video-tutorial/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ssas-forecast-video-tutorial</link>
		<comments>http://ricardo.parente.us/2010/12/ssas-forecast-video-tutorial/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 17:12:01 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[Forecast Tool]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=4428</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="505" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/2SOr3wKf2sA?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="505" src="http://www.youtube.com/v/2SOr3wKf2sA?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2010/12/ssas-forecast-video-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Congratulations Pinal Dave for the 1500th Post</title>
		<link>http://ricardo.parente.us/2010/10/congratulations-pinal-dave-for-the-1500th-post/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=congratulations-pinal-dave-for-the-1500th-post</link>
		<comments>http://ricardo.parente.us/2010/10/congratulations-pinal-dave-for-the-1500th-post/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 16:57:47 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL Authority]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=3760</guid>
		<description><![CDATA[Pinal Dave, my SQL Guru, completed today 1500 posts on his blog SQLAuthority, with 20 million views in iyts 4th year. That&#8217;s amazing! Good job. He explains how he came up with the blog&#8217;s name on this article. Keep up the good work Pinal !]]></description>
			<content:encoded><![CDATA[<p>Pinal Dave, my SQL Guru, completed today 1500 posts on his blog <a title="http://blog.sqlauthority.com" href="http://blog.sqlauthority.com" target="_blank"><strong>SQLAuthority</strong></a>, with 20 million views in iyts 4th year.</p>
<p>That&#8217;s amazing! Good job.</p>
<p>He explains how he came up with the blog&#8217;s name on this <a title="http://blog.sqlauthority.com/2010/10/14/sql-server-1500-posts-a-milestone-original-of-blog-name-revealed/" href="http://blog.sqlauthority.com/2010/10/14/sql-server-1500-posts-a-milestone-original-of-blog-name-revealed/" target="_blank"><strong>article</strong></a>.</p>
<p>Keep up the good work Pinal !</p>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2010/10/congratulations-pinal-dave-for-the-1500th-post/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ColdFusion &#8211; SQL: Dynamic Values in Order By Clause</title>
		<link>http://ricardo.parente.us/2010/10/coldfusion-sql-dynamic-values-in-order-by-clause/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coldfusion-sql-dynamic-values-in-order-by-clause</link>
		<comments>http://ricardo.parente.us/2010/10/coldfusion-sql-dynamic-values-in-order-by-clause/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 16:41:31 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[RANK()]]></category>
		<category><![CDATA[row_number]]></category>
		<category><![CDATA[T-Sql]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=3605</guid>
		<description><![CDATA[This week I had to write a stored procedure for retrieving real estate properties and use the data in a ColdFusion template with pagination.  I had the following input arguments: StartRow, EndRow, PriceFrom, PriceTo and SortBy. Since I use Fusebox, all parameters passed in the URL query string are converted to the scope &#8220;attributes&#8221;.  So, [...]]]></description>
			<content:encoded><![CDATA[<p>This week I had to write a stored procedure for retrieving real estate properties and use the data in a ColdFusion template with pagination.  I had the following input arguments: StartRow, EndRow, PriceFrom, PriceTo and SortBy.</p>
<p>Since I use Fusebox, all parameters passed in the URL query string are converted to the scope &#8220;attributes&#8221;.  So, here is the procedure call:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
</pre>
<pre>&lt;cfstoredproc procedure=&quot;dbo.pagination&quot; datasource=&quot;#application.mainDSN#&quot;&gt;
&lt;cfprocparam cfsqltype=&quot;cf_SQL_INTEGER&quot; value=&quot;#attributes.startRow#&quot;  /&gt;
&lt;cfprocparam cfsqltype=&quot;cf_SQL_INTEGER&quot; value=&quot;#attributes.endRow#&quot; /&gt;
&lt;cfprocparam cfsqltype=&quot;cf_SQL_INTEGER&quot; value=&quot;#attributes.priceFrom#&quot; null=&quot;#(not len(trim(attributes.priceFrom)))#&quot; /&gt;
&lt;cfprocparam cfsqltype=&quot;cf_SQL_INTEGER&quot; value=&quot;#attributes.sortBy#&quot; null=&quot;#(not len(trim(attributes.sortBy)))#&quot; /&gt;
&lt;cfprocresult name=&quot;qProps&quot; /&gt;
&lt;/cfstoredproc&gt;</pre>
</div>
<p><span id="more-3605"></span> You may have noticed that some parameters if not passed to this template, it will send a NULL value to the store procedure.</p>
<p>Since the SortBy parameter is dynamic and I need to retrieve only a subset of the query, I mean, the amount of records to fit one page, I could not use CTE because SQL Server does not allow the ORDER BY clause in the CTE (temporary table). Also, we needed to have a CASE statement in the ODER BY clause to allow dynamic sorting.</p>
<p>After such a pain in the neck, I did some research and found some examples on<strong> <a title="http://blog.sqlauthority.com/2007/07/17/sql-server-case-statement-in-order-by-clause-order-by-using-variable/" href="http://blog.sqlauthority.com/2007/07/17/sql-server-case-statement-in-order-by-clause-order-by-using-variable/" target="_blank">Pinal Dave</a></strong> blog &#8220;<a title="http://search.sqlauthority.com/" href="http://search.sqlauthority.com/" target="_blank"><strong>SQL Authority</strong></a>&#8220;. One of the comments on his article suggested the use of RANK(), and that was it, the solution for my problem.</p>
<p>Here is the stored procedure:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
</pre>
<pre>CREATE PROCEDURE [dbo].[Pagination]
@arg_startRow int
,   @arg_endRow int
,   @arg_priceFrom money = NULL
,   @arg_priceTo money = NULL
,   @arg_sortBy varchar(50) = NULL

AS
BEGIN
SET NOCOUNT ON;
DECLARE @temp table (
propertyUUID uniqueidentifier
,   price money
,   yearBuilt smallint
,   cityName nvarchar(50)
,   rowNum int
)
INSERT INTO @temp
SELECT
p.propertyUUID
,   p.price
,   p.yearBuilt
,   c.cityName
,   rowNum =
CASE
WHEN (@arg_sortBy = &#039;price ASC&#039;) THEN
ROW_NUMBER() OVER(ORDER BY p.price)
WHEN (@arg_sortBy = &#039;price DESC&#039;) THEN
ROW_NUMBER() OVER(ORDER BY p.price DESC)
-- default order
ELSE ROW_NUMBER() OVER(ORDER BY c.cityName)
END
FROM dbo.properties p
LEFT JOIN dbo.cities c ON c.cityCode = p.cityCode
WHERE p.isActive = 1
AND (@arg_priceFrom IS NULL OR p.price &gt;= @arg_priceFrom)
AND (@arg_priceTo IS NULL OR p.price &lt;= @arg_priceTo)
AND (@arg_cityName IS NULL OR c.cityName = @arg_cityName)
ORDER BY
CASE
WHEN @arg_sortBy = &#039;price ASC&#039; THEN
RANK() OVER(ORDER BY p.price)
WHEN @arg_sortBy = &#039;price DESC&#039; THEN
RANK() OVER(ORDER BY p.price DESC)
ELSE c.cityName
END

-- Now select only the number of rows passed from the pagination request
SELECT
propertyUUID
,   cityName
,   price
,   yearBuilt
FROM @temp
WHERE rowNum BETWEEN @arg_startRow AND @arg_endRow</pre>
</div>
<p>With that SP we can now paginate without losing the order by set by the url parameter.</p>
<p>Thanks Pinal Dave!</p>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2010/10/coldfusion-sql-dynamic-values-in-order-by-clause/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL: Tips for Where Clause With Wildcards</title>
		<link>http://ricardo.parente.us/2010/10/sql-tips-for-where-clause-with-wildcards/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sql-tips-for-where-clause-with-wildcards</link>
		<comments>http://ricardo.parente.us/2010/10/sql-tips-for-where-clause-with-wildcards/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 03:24:38 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[T-Sql]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=3601</guid>
		<description><![CDATA[We, at the company,  had to find all cities in my city table which name were composed of more than one word and the last word should have only two characters, like &#8220;Berlin SO&#8221;, &#8220;Santa Fe&#8221;&#8230; Phillip Gagnon, our I.T. manager, showed us two simple ways to list them using wildcards: 1 2 3 SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>We, at the company,  had to find all cities in my city table which name were composed of more than one word and the last word should have only two characters, like &#8220;Berlin SO&#8221;, &#8220;Santa Fe&#8221;&#8230;</p>
<p>Phillip Gagnon, our I.T. manager, showed us two simple ways to list them using wildcards:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
</pre>
<pre>SELECT cityID, cityName
FROM cities
WHERE right(cityName, 3) like &#039; __&#039;</pre>
</div>
<p>and another way:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
</pre>
<pre>SELECT cityID, cityName
FROM cities
WHERE right(cityName, 3) like &#039; %%&#039;</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2010/10/sql-tips-for-where-clause-with-wildcards/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft SQL Server 2008 Service Pack 2</title>
		<link>http://ricardo.parente.us/2010/09/microsoft-sql-server-2008-service-pack-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-sql-server-2008-service-pack-2</link>
		<comments>http://ricardo.parente.us/2010/09/microsoft-sql-server-2008-service-pack-2/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 16:40:30 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Microsoft SQL Server 2008]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[Service Pack 2]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=3590</guid>
		<description><![CDATA[Microsoft released the SQL 2008 Service Pack 2. You may download it here. Reference: Pinal Dave]]></description>
			<content:encoded><![CDATA[<p>Microsoft released the SQL 2008 Service Pack 2.</p>
<p>You may download it <a title="Microsoft SQL Server 2008 Service Pack 2" href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17" target="_blank"><strong>here.</strong></a></p>
<p>Reference: <a title="Pinal Dave" href="http://blog.sqlauthority.com/2010/09/30/sql-server-microsoft-sql-server-2008-service-pack-2-download/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+SQLAuthority+%28Journey+to+SQL+Authority+with+Pinal+Dave%29" target="_blank"><strong>Pinal Dave</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2010/09/microsoft-sql-server-2008-service-pack-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert String to a Table using CTE</title>
		<link>http://ricardo.parente.us/2009/12/convert-string-to-a-table-using-cte/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=convert-string-to-a-table-using-cte</link>
		<comments>http://ricardo.parente.us/2009/12/convert-string-to-a-table-using-cte/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 20:45:42 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[CTE]]></category>
		<category><![CDATA[MS SQL 2005]]></category>
		<category><![CDATA[string to table]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=1290</guid>
		<description><![CDATA[I have found many solutions to pass a list parameter from ColdFusion to a stored procedure, and this one is a very simple and efficient way to convert a string to a table. Thanks to Amit Gaur posting to SQL ServerCentral. I modified his original function which returns only integers (forcing you to pass only [...]]]></description>
			<content:encoded><![CDATA[<p>I have found many solutions to pass a list parameter from ColdFusion to a stored procedure,<br />
and this one is a very simple and efficient way to convert a string to a table. Thanks to <strong>Amit Gaur</strong> posting to <a title="SQL Server Central" href="http://www.sqlservercentral.com/articles/CTE/67974/" target="_blank"><strong>SQL ServerCentral</strong></a>.</p>
<p>I modified his original function which returns only integers (forcing you to pass only a list of integers).</p>
<p>Suppose you pass the string &#8217;2A354,FB452,8896&#8242; in the argument @itemList as a list of item codes you want to retrieve from your inventory table.</p>
<p><span id="more-1290"></span></p>
<p>In your stored procedure you would have this query:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
</pre>
<pre>SELECT item, description, price
FROM inventory
WHERE item IN (SELECT item FROM strToTable(@itemList))</pre>
</div>
<p>Here is the function strToTable():</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
39
40
41
</pre>
<pre>SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        Amit Gaur
-- Create date: July 25th 2008
-- Description:    Convert a string to a table
-- =============================================
CREATE FUNCTION [dbo].[strToTable]
(
@array varchar(max),
@del char(1)
)
RETURNS
@listTable TABLE
(
item int
)
AS
BEGIN

WITH rep (item,list) AS
(
SELECT SUBSTRING(@array,1,CHARINDEX(@del,@array,1) - 1) as item,
SUBSTRING(@array,CHARINDEX(@del,@array,1) + 1, LEN(@array)) + @del list

UNION ALL

SELECT SUBSTRING(list,1,CHARINDEX(@del,list,1) - 1) as item,
SUBSTRING(list,CHARINDEX(@del,list,1) + 1, LEN(list)) list
FROM rep
WHERE LEN(rep.list) &gt; 0
)
INSERT INTO @listTable
SELECT item FROM rep

RETURN
END

GO</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2009/12/convert-string-to-a-table-using-cte/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Copying Stored Procedures to Another Server</title>
		<link>http://ricardo.parente.us/2009/09/copying-stored-procedures-to-another-server/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=copying-stored-procedures-to-another-server</link>
		<comments>http://ricardo.parente.us/2009/09/copying-stored-procedures-to-another-server/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 02:03:27 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=947</guid>
		<description><![CDATA[We are constantly implementing new tasks and developing web sites for about 12 customers. We have a development server at our office and our live servers are at our datacenter. Many times we have to rewrite or modify stored procedures and then after testing, we need to copy them to the live server. To accomplish [...]]]></description>
			<content:encoded><![CDATA[<p>We are constantly implementing new tasks and developing web sites for about 12 customers. We have a development server at our office and our live servers are at our datacenter. Many times we have to rewrite or modify stored procedures and then after testing, we need to copy them to the live server.<br />
<span id="more-947"></span><br />
To accomplish this task we could normally script the SPs and copy the scripts to the live server, but that would take us a lot of time. The solution was written by our colleague <a title="Phillip Gagnon Blog" href="http://phillipgagnon.com" target="_blank"><strong>Phillip Gagnon</strong></a>, who wrote a piece of code to automate that task of copying from dev to live.<br />
I found it interesting and with his permission I&#8217;m posting it here.</p>
<p>Here is the code,you may call it <em>pushToLive.cfm</em>:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">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
39
40
</pre>
<pre>&lt;cfparam name=&quot;url.devDsn&quot; default=&quot;myDevDSN&quot;&gt;
&lt;cfparam name=&quot;url.liveDsn&quot; default=&quot;myLiveDSN&quot;&gt;
&lt;cfparam name=&quot;url.output&quot; default=&quot;false&quot;&gt;
&lt;cfquery name=&quot;qProcs&quot; datasource=&quot;#devDsn#&quot;&gt;
     SELECT o.name, c.text
     FROM sysobjects o LEFT JOIN dbo.syscomments c ON o.id=c.id
     WHERE xType=&#039;P&#039; and category=0
&lt;/cfquery&gt;
&lt;cfoutput&gt;
There are #qProcs.recordCount# procedures to overwrite&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;cfflush&gt;
&lt;cfset i=1&gt;
&lt;cfloop query=&quot;qProcs&quot;&gt;
     &lt;cfquery datasource=&quot;#liveDsn#&quot;&gt;
          IF EXISTS(SELECT name FROM sysobjects WHERE name = &#039;#name#&#039; AND type = &#039;P&#039;)
               DROP PROCEDURE #name#
     &lt;/cfquery&gt;
     &lt;cfif url.output&gt;
          &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
          #text#
          &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
          &lt;cfflush&gt;
     &lt;/cfif&gt;
     &lt;cftry&gt;
          #i#. Writing #name#&lt;br /&gt;
          &lt;cfflush&gt;
          &lt;cfquery datasource=&quot;#liveDsn#&quot;&gt;
               #preserveSingleQuotes(text)#
          &lt;/cfquery&gt;
          &lt;cfcatch type=&quot;any&quot;&gt;
               &lt;h1 style=&quot;color:red;&quot;&gt;Error Writing #qProcs.name#&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
               #qProcs.text#&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
               &lt;cfdump var=&quot;#cfcatch#&quot;&gt;
          &lt;/cfcatch&gt;
     &lt;/cftry&gt;
     &lt;cfset i=i+1&gt;
&lt;/cfloop&gt;
&lt;br /&gt;
Done!&lt;br /&gt;
&lt;/cfoutput&gt;</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2009/09/copying-stored-procedures-to-another-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Advanced SQL Injection</title>
		<link>http://ricardo.parente.us/2009/07/advanced-sql-injection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=advanced-sql-injection</link>
		<comments>http://ricardo.parente.us/2009/07/advanced-sql-injection/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 03:44:27 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Amsterdam]]></category>
		<category><![CDATA[Black Hat Briefings]]></category>
		<category><![CDATA[Europe]]></category>
		<category><![CDATA[SQL Injection]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=743</guid>
		<description><![CDATA[My friend Pedro Claudio posted a link on my Facebook Wall about this presentation made by Bernardo D. A. Guimarães at the Black Hat Briefings Europe, Amsterdam in April 2009. I found it interesting and here is the slide presentation: Advanced SQL injection to operating system full control (slides) View more documents from Bernardo Damele [...]]]></description>
			<content:encoded><![CDATA[<p>My friend Pedro Claudio posted a link on my Facebook Wall about this presentation made by <a title="Bernardo D. A. Guimaraes" href="http://www.slideshare.net/inquis" target="_blank"><strong>Bernardo D. A. Guimarães</strong></a> at the Black Hat Briefings Europe, Amsterdam in April 2009. I found it interesting and here is the slide presentation:</p>
<div id="__ss_1316179" style="width: 425px; text-align: left;"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" title="Advanced SQL injection to operating system full control (slides)" href="http://www.slideshare.net/inquis/advanced-sql-injection-to-operating-system-full-control-slides">Advanced SQL injection to operating system full control (slides)</a><object style="margin:0px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=blackhat-europe-09-dameleag-advancedsqlinjection-slides-090420100219-phpapp02&amp;stripped_title=advanced-sql-injection-to-operating-system-full-control-slides" /><param name="allowfullscreen" value="true" /><embed style="margin:0px" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=blackhat-europe-09-dameleag-advancedsqlinjection-slides-090420100219-phpapp02&amp;stripped_title=advanced-sql-injection-to-operating-system-full-control-slides" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/inquis">Bernardo Damele a. g.</a>.</div>
</div>
<input id="gwProxy" type="hidden" />
<input id="jsProxy" onclick="jsCall();" type="hidden" />
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2009/07/advanced-sql-injection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert Time To Decimal (SQL)</title>
		<link>http://ricardo.parente.us/2009/06/convert-time-to-decimal-sql/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=convert-time-to-decimal-sql</link>
		<comments>http://ricardo.parente.us/2009/06/convert-time-to-decimal-sql/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 14:34:13 +0000</pubDate>
		<dc:creator>rparente</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[convert time]]></category>
		<category><![CDATA[functions]]></category>

		<guid isPermaLink="false">http://ricardo.parente.us/?p=581</guid>
		<description><![CDATA[I was following the SQL list and came across a post from Jim Gotwald where he showed his solution to convert a time string into a decimal value (ex: &#8217;10:30&#8242; to 10.5). So I decided to write a custom function where you can either pass a complete date as a string or just the time [...]]]></description>
			<content:encoded><![CDATA[<p>I was following the SQL list and came across a post from <strong>Jim Gotwald</strong> where he showed his solution to convert a time string into a decimal value (ex: &#8217;10:30&#8242; to 10.5).</p>
<p>So I decided to write a custom function where you can either pass a complete date as a string or just the time and it will return a float value representing the time in decimal.</p>
<p>You may call the function like this:</p>
<p>select dbo.timeToDecimal(cast(getDate()) as varchar(20))<br />
select dbo.timeToDecimal(&#8217;2008-06-18 10:35:43&#8242;)<br />
select dbo.timeToDecimal(&#8217;06/18/2009 10:22:00&#8242;)<br />
select dbo.timeToDecimal(&#8217;10:42&#8242;)</p>
<p><span id="more-581"></span></p>
<p>Here is the function:<code><br />
SET ANSI_NULLS ON<br />
GO<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
-- =============================================<br />
-- Author:        Ricardo Parente<br />
-- Create date: 2009-06-18<br />
-- Description:    I convert a time string to decimal<br />
-- Parameter: datetime string (varchar) or just a time string<br />
-- =============================================<br />
CREATE FUNCTION dbo.timeToDecimal<br />
(<br />
@timeToConvert varchar(25)<br />
)<br />
RETURNS float<br />
AS<br />
BEGIN<br />
DECLARE @Result float<br />
DECLARE @t varchar(5)<br />
SET @t = cast(datepart(hh,@timeToConvert) as varchar(2)) + ':' + cast(datepart(n,@timeToConvert) as varchar(2))<br />
SET @Result = CAST(DATEDIFF(N, '00:00', @t) AS FLOAT)/60<br />
RETURN @Result<br />
END<br />
GO<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://ricardo.parente.us/2009/06/convert-time-to-decimal-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

