<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Usama&#039;s Blog</title>
	<atom:link href="http://usamafahmed.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://usamafahmed.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Fri, 23 Dec 2011 10:54:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='usamafahmed.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Usama&#039;s Blog</title>
		<link>http://usamafahmed.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://usamafahmed.wordpress.com/osd.xml" title="Usama&#039;s Blog" />
	<atom:link rel='hub' href='http://usamafahmed.wordpress.com/?pushpress=hub'/>
		<item>
		<title>SSRS &#8211; How to put a LINE FEED and a CHECK BOX</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/ssrs-how-to-put-a-line-feed-and-a-check-box/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/ssrs-how-to-put-a-line-feed-and-a-check-box/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 22:53:14 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Computer]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[New]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[work around]]></category>
		<category><![CDATA[Put]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[box]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[checked box]]></category>
		<category><![CDATA[checkedbox]]></category>
		<category><![CDATA[line feed]]></category>
		<category><![CDATA[carriage return]]></category>
		<category><![CDATA[enter]]></category>
		<category><![CDATA[next]]></category>
		<category><![CDATA[use get]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[immitate]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=302</guid>
		<description><![CDATA[I have found the below  somewhere in the internet but I don&#8217;t remember where: &#8211;&#62;&#62; Line Feed &#8211; Newlines in text boxes If you&#8217;re using an expression to build up a paragraph or two of text in a text box and need a new line, use this: VBCRLF (Visual Basic Carriage Return Line Feed for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=302&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have found the below  somewhere in the internet but I don&#8217;t remember where:<br />
&#8211;&gt;&gt; Line Feed<br />
&#8211; Newlines in text boxes<br />
If you&#8217;re using an expression to build up a paragraph or two of text in a text box and need a new line, use this:<br />
VBCRLF (Visual Basic Carriage Return Line Feed for those who&#8217;re interested!)</p>
<p>E.g. =&#8221;This is line 1&#8243; + VBCRLF + &#8220;This isn&#8217;t&#8221; will produce:<br />
This is line 1<br />
This isn&#8217;t</p>
<p>Gotcha: If VBCRLF is the first or last thing in your text box, Reporting Services will ignore it (I have no idea why!). Make sure you put in one extra VBCRLF at the beginning or end if you&#8217;re using them there.<br />
&#8212;- &gt;&gt;&gt;</p>
<p>- &#8211; Checkboxes<br />
I would have thought it would be fairly common to want to display a check box on a report which is checked based on a value in the dataset but it would appear that it&#8217;s not so common as there is no control provided to handle this. If your client, like mine, really wants a checkbox displayed on a report, you&#8217;ll need to use wingdings. Yes, you heard right, add a small text box to your report, set the font to wingdings and use something like the following expression:<br />
=iif(Fields!BookingMade.Value = &#8220;1&#8243;,chr(0254),&#8221;o&#8221;)</p>
<p><strong>Checked Box &gt; Wingding 2 =chr(82) </strong><br />
<strong>Unchecked Box &gt; Wingding 2 =chr(163)</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/302/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=302&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/ssrs-how-to-put-a-line-feed-and-a-check-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>Tool &#8211; Transpose &amp; Put Comma &#8211; Copy all values from a field</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/tool-transpose-put-comma-copy-all-values-from-a-field/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/tool-transpose-put-comma-copy-all-values-from-a-field/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 11:12:03 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Explanations]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Tool]]></category>
		<category><![CDATA[all]]></category>
		<category><![CDATA[Comma]]></category>
		<category><![CDATA[Copy]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[Put]]></category>
		<category><![CDATA[Transpose]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[values]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=289</guid>
		<description><![CDATA[&#8211; This snippet lists all given the field vlaues so that they straight away be copied and put into a string. &#8211; i.e.  set @variable = &#8216;a,b,c,d,e&#8217; &#8212; the text inside the single quote is generated &#8211; Change the below sql in the singel quote to replace it with the required field and table name. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=289&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211; This snippet lists all given the field vlaues so that they straight away be copied and put into a string.</p>
<p>&#8211; i.e.  set @variable = &#8216;a,b,c,d,e&#8217; &#8212; the text inside the single quote is generated</p>
<p>&#8211; Change the below sql in the singel quote to replace it with the required field and table name.</p>
<p>&#8211; Delete or change the top 100 to the number of values you want it returned</p>
<p>&#8211; Also remember to be inside the server and the database the table is in.</p>
<p>&#8211; Go to the &#8220;MESSAGES&#8221; tab and copy the piece of text into the clipboard for later use.</p>
<p>declare @passed varchar(max)</p>
<p>set @passed = &#8216;SELECT top 100 [place the field name here] from [place the table name here]&#8216;</p>
<p>Declare @fetch table</p>
<p>(</p>
<p>id int identity,</p>
<p>store varchar(max)</p>
<p>)</p>
<p>if left(ltrim(@passed), 6) = &#8216;select&#8217;</p>
<p>begin</p>
<p>insert into @fetch</p>
<p>exec (@passed)</p>
<p>end</p>
<p>select * from @fetch</p>
<p>declare @id int, &#8212; Pointer</p>
<p>@idMax int, &#8212; Scroller</p>
<p>@pipe varchar(max) &#8212; Final string to return</p>
<p>select @id = 0, @idMax = max(id), @pipe = &#8221;</p>
<p>from @fetch</p>
<p>while @id &lt; @idMax &#8212; whenever @id would be = @idMax; the loop would break</p>
<p>begin</p>
<p>set @id = @id + 1 &#8212; Start Scrolling</p>
<p>select @pipe = case when @id &lt; @idMax then @pipe + store + &#8216;, &#8216;</p>
<p>else @pipe + store end &#8212; We dont want a comma at the end of the string</p>
<p>from @fetch where id = @id &#8212; tells which record to fetch</p>
<p>end</p>
<p>print @pipe</p>
<p>&#8211; Please check the screen shot below:</p>
<p>&#8211; I have used the below query:</p>
<p>&#8211; SELECT name FROM dbo.sysobjects WHERE type = &#8216;u&#8217;</p>
<p><span style="font-size:small;font-family:Calibri;"> </span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-size:small;font-family:Calibri;"><a href="http://usamafahmed.files.wordpress.com/2011/10/transposeputcomma1.jpg"><img class="size-medium wp-image-291 alignleft" title="Transpose&amp;PutComma" src="http://usamafahmed.files.wordpress.com/2011/10/transposeputcomma1.jpg?w=300&#038;h=117" alt="" width="300" height="117" /></a></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>I have also made an excel file that does a similar job but it is limited to the number of rows. Just copy and past the the fields values in the left most column and press ctrl + d</p>
<p>Click the link below to download it:</p>
<p><a title="Download Excel file - Transpose and put comma" href="http://www.4shared.com/document/XNPfUB-U/Transpose_and_put_commas.html" target="_blank">Link to download</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=289&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/tool-transpose-put-comma-copy-all-values-from-a-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>

		<media:content url="http://usamafahmed.files.wordpress.com/2011/10/transposeputcomma1.jpg?w=300" medium="image">
			<media:title type="html">Transpose&#38;PutComma</media:title>
		</media:content>
	</item>
		<item>
		<title>SSRS &#8211; Restrict Months</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/ssrs-restrict-months/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/ssrs-restrict-months/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 10:38:43 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[available]]></category>
		<category><![CDATA[month]]></category>
		<category><![CDATA[required]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[Usama]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=284</guid>
		<description><![CDATA[&#8211; For use with usp_getMonth (which can be found in the Second Option in the post &#8211; http://wp.me/pAchH-4l) &#8211; The below can be used when in SSRS you only want to show the months which are available for the users to select. This requires the the a parameter which would return the year selected =iif(Parameters!Year.Value [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=284&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211; For use with usp_getMonth (which can be found in the Second Option in the post &#8211; http://wp.me/pAchH-4l)</p>
<p>&#8211; The below can be used when in SSRS you only want to show the months which are available for the users to select. This requires the the a parameter which would return the year selected</p>
<p>=iif(Parameters!Year.Value = year(today()), month(today()), 12)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=284&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/ssrs-restrict-months/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>SSRS &#8211; Select available months</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/ssrs-select-available-months/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/ssrs-select-available-months/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 10:08:21 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=276</guid>
		<description><![CDATA[&#8211; For use with usp_getMonth (which can be found in the Second Option in the post &#8211; http://wp.me/pAchH-4l) &#8211; The below can be used when in SSRS you only want to show the months which are available for the users to select. This requires the the a parameter which would return the year selected =iif(Parameters!Year.Value [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=276&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211; For use with usp_getMonth (which can be found in the Second Option in the post &#8211; http://wp.me/pAchH-4l)</p>
<p>&#8211; The below can be used when in SSRS you only want to show the months which are available for the users to select. This requires the the a parameter which would return the year selected</p>
<p>=iif(Parameters!Year.Value = year(today()), month(today()), 12)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/276/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=276&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/ssrs-select-available-months/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>TSQL &#8211; Returns the Week Day Names &amp; Numbers</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/tsql-returns-the-week-day-names-numbers/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/tsql-returns-the-week-day-names-numbers/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:54:19 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[Day]]></category>
		<category><![CDATA[defined]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[Name]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[returns]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[uder]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[use]]></category>
		<category><![CDATA[Week]]></category>
		<category><![CDATA[year]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=274</guid>
		<description><![CDATA[&#8211; Returns the Week Day Names and its correponding Week Number (taking Sunday as 1) &#8211;================================================== &#8211;alter proc dbo.usp_getWeekDayNames &#8211;as set Datefirst 1 &#8212; Monday is set to be the first day of the week declare @c int set @c = 1 declare @WeekDays table ( WeekDayNumber int, WeekDayName varchar(12) ) while (@c &#60;= 7) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=274&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211; Returns the Week Day Names and its correponding Week Number (taking Sunday as 1)<br />
&#8211;==================================================</p>
<p>&#8211;alter proc dbo.usp_getWeekDayNames<br />
&#8211;as</p>
<p>set Datefirst 1 &#8212; Monday is set to be the first day of the week<br />
declare @c int<br />
set @c = 1</p>
<p>declare @WeekDays table<br />
(<br />
WeekDayNumber int,<br />
WeekDayName varchar(12)<br />
)</p>
<p>while (@c &lt;= 7)<br />
begin<br />
insert @WeekDays<br />
select datepart(weekday, dateadd(day, @c, getdate())) WeekDayNumber,<br />
datename(weekday, dateadd(day, @c, getdate() )) WeekDayName<br />
set @c = @c + 1<br />
end</p>
<p>select *<br />
from @WeekDays<br />
order by 1</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/274/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/274/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/274/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=274&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/tsql-returns-the-week-day-names-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>TSQL &#8211; Produce the start and end times in given interval in 24 hours</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/tsql-produce-the-start-and-end-times-in-given-interval-in-24-hours/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/tsql-produce-the-start-and-end-times-in-given-interval-in-24-hours/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:49:58 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Explanations]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[24]]></category>
		<category><![CDATA[defined]]></category>
		<category><![CDATA[end]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[hours]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[interval]]></category>
		<category><![CDATA[Produce]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[times]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[uder]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=273</guid>
		<description><![CDATA[&#8211;Description:    Returns the Start Time and Stop Time columns from udf_EvenlySlice24hours in minutes (this udf can also be found in my posts) &#8211;alter proc dbo.usp_getTimeSlicedInMin (@Interval int) &#8211;as &#8212;- ==== Test Data ===== declare @Interval int set @Interval = 60 &#8212;- ======================== select left(StartTime, len(StartTime)-3) StartTime, left(StopTime, len(StopTime)-3) StopTime , LEFT(StartTime,2) * 60 + RIGHT(LEFT(StartTime,5),2) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=273&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211;Description:    Returns the Start Time and Stop Time columns from udf_EvenlySlice24hours in minutes (this udf can also be found in my posts)<br />
&#8211;alter proc dbo.usp_getTimeSlicedInMin (@Interval int)<br />
&#8211;as</p>
<p>&#8212;- ==== Test Data =====<br />
declare @Interval int<br />
set @Interval = 60<br />
&#8212;- ========================</p>
<p>select left(StartTime, len(StartTime)-3) StartTime, left(StopTime, len(StopTime)-3) StopTime<br />
, LEFT(StartTime,2) * 60 + RIGHT(LEFT(StartTime,5),2) StartTimeInMin<br />
, LEFT(StopTime,2) * 60 + RIGHT(LEFT(StopTime,5),2) + 1 StopTimeInMin&#8211; one has to be added is added (see notes below)<br />
from udf_EvenlySlice24hours (@Interval)</p>
<p>/*  ====== Notes</p>
<p>1 is added to StopTimeInMin so that in the calling SP  the parameter  passed by the user need can include<br />
the last minute till which he wants to end time this is done for user friedliness, so for example  if the user wants to end the timer at 5pm then<br />
he shoud put in 1020 = (17 * 60) later on in the code 3 mc should deducted like below<br />
@StopTime = DATEADD(ms,-3, dateadd(minute, [last minute till which he wants to end time], @StopTime)) &#8212; Subtract -3 ms to get the last time</p>
<p>*/</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/273/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=273&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/tsql-produce-the-start-and-end-times-in-given-interval-in-24-hours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>TSQL &#8211; Return Month Name &amp; Number (2 Options)</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/tsql-return-month-name-number-2-options/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/tsql-return-month-name-number-2-options/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:42:08 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Explanations]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[defined]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[month]]></category>
		<category><![CDATA[Name]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[uder]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=269</guid>
		<description><![CDATA[&#8211; There are two SPs here &#8211;First option:    Returns all month name and number &#8211;================================================== &#8211;create proc dbo.usp_getMonthNameAndNumber &#8211;as declare @allMonths table ( MonthNumber int identity, MonthName varchar(10) ) declare @count int set @count = 0 while (@count &#60; 12) begin insert @allMonths select dateName(month,dateadd(month, @count, &#8217;1 Jan 2010&#8242;)) set @count = @count + 1 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=269&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211; There are two SPs here</p>
<p>&#8211;First option:    Returns all month name and number</p>
<p>&#8211;==================================================</p>
<p>&#8211;create proc dbo.usp_getMonthNameAndNumber<br />
&#8211;as</p>
<p>declare @allMonths table<br />
(<br />
MonthNumber int identity,<br />
MonthName varchar(10)<br />
)</p>
<p>declare @count int<br />
set @count = 0</p>
<p>while (@count &lt; 12)<br />
begin<br />
insert @allMonths<br />
select dateName(month,dateadd(month, @count, &#8217;1 Jan 2010&#8242;))<br />
set @count = @count + 1<br />
end</p>
<p>select * from @allMonths order by 1</p>
<p>&#8211;Second option:    Returns Month name and number upto the passed month number<br />
&#8211;    (rows are restricted to the passed month)</p>
<p>&#8211;==================================================</p>
<p>&#8211;create proc dbo.usp_getMonth (@RestrictToMonthNumber int = null)<br />
&#8211;as</p>
<p>&#8212;&#8212;&#8212;====== Test Values ======<br />
DECLARE @RestrictToMonthNumber int<br />
set @RestrictToMonthNumber = 6<br />
&#8212;&#8212;-=============================</p>
<p>&#8211; Note: If null is sent then all months are returned</p>
<p>declare @allMonths table<br />
(<br />
MonthNumber int identity,<br />
MonthName varchar(10)<br />
)</p>
<p>if @RestrictToMonthNumber is null set @RestrictToMonthNumber = 12</p>
<p>declare @count int<br />
set @count = 0</p>
<p>while (@count &lt; @RestrictToMonthNumber )<br />
begin<br />
insert @allMonths<br />
select dateName(month,dateadd(month, @count, &#8217;1 Jan 2010&#8242;))<br />
set @count = @count + 1<br />
end</p>
<p>select * from @allMonths order by 1</p>
<p>&nbsp;</p>
<p>Related post *used in SSRS):</p>
<p>http://wp.me/pAchH-4A</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/269/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=269&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/tsql-return-month-name-number-2-options/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>TSQL &#8211; Extract Numbers From String to Float</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/tsql-extract-numbers-from-string-to-float/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/tsql-extract-numbers-from-string-to-float/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:38:47 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[defined]]></category>
		<category><![CDATA[Extract]]></category>
		<category><![CDATA[float]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[uder]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=265</guid>
		<description><![CDATA[&#8211;create function dbo.udf_ExtractNumbersToFloat (@String varchar(max)) &#8211;returns float &#8211;begin &#8212;&#8212; ==== Test ======= DECLARE @String varchar(1000) SET @String = &#8216;I can count 1 and 2 and 3 even 4.5&#8242;; &#8212;&#8212; ==== Test ======= WHILE PATINDEX(&#8216;%[^0-9]%.%&#8217;,@String)&#62; 0 SET @String = REPLACE(@String,SUBSTRING(@String,PATINDEX(&#8216;%[^0-9]%&#8217;,@String),1),&#8221;) declare @Float float set @Float = convert(float, @String) PRINT @Float &#8212; test &#8211;    return  @Float &#8211;end<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=265&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211;create function dbo.udf_ExtractNumbersToFloat (@String varchar(max))<br />
&#8211;returns float<br />
&#8211;begin<br />
&#8212;&#8212; ==== Test =======<br />
DECLARE @String varchar(1000)<br />
SET @String = &#8216;I can count 1 and 2 and 3 even 4.5&#8242;;<br />
&#8212;&#8212; ==== Test =======</p>
<p>WHILE PATINDEX(&#8216;%[^0-9]%.%&#8217;,@String)&gt; 0<br />
SET @String = REPLACE(@String,SUBSTRING(@String,PATINDEX(&#8216;%[^0-9]%&#8217;,@String),1),&#8221;)</p>
<p>declare @Float float<br />
set @Float = convert(float, @String)</p>
<p>PRINT @Float &#8212; test<br />
&#8211;    return  @Float<br />
&#8211;end</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/265/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/265/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/265/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=265&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/tsql-extract-numbers-from-string-to-float/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>TSQL &#8211; Evenly divide 24 hour into given minutes &#8211; Returns table</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/tsql-evenly-divide-24-hour-into-given-minutes-returns-table/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/tsql-evenly-divide-24-hour-into-given-minutes-returns-table/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:35:59 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[24]]></category>
		<category><![CDATA[defined]]></category>
		<category><![CDATA[divide]]></category>
		<category><![CDATA[Evenly]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[given]]></category>
		<category><![CDATA[hour]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[minute]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[uder]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=267</guid>
		<description><![CDATA[create function dbo.udf_EvenlySlice24hours (@Interval int) returns @timePeriods  table ( StartTime varchar(8) null, StopTime varchar(8) null ) as begin &#8212;&#8212; ==== Test ======= &#8211;Declare @Interval int &#8211;set @Interval = 60 &#8212; User can put in any minute here &#8212;- Skeleton to hold &#8211;declare @timePeriods table &#8211;( &#8211;    StartTime varchar(8) null, &#8211;    StopTime varchar(8) null &#8211;) &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=267&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>create function dbo.udf_EvenlySlice24hours (@Interval int)<br />
returns @timePeriods  table<br />
(<br />
StartTime varchar(8) null,<br />
StopTime varchar(8) null<br />
)<br />
as<br />
begin</p>
<p>&#8212;&#8212; ==== Test =======<br />
&#8211;Declare @Interval int<br />
&#8211;set @Interval = 60 &#8212; User can put in any minute here<br />
&#8212;- Skeleton to hold<br />
&#8211;declare @timePeriods table<br />
&#8211;(<br />
&#8211;    StartTime varchar(8) null,<br />
&#8211;    StopTime varchar(8) null<br />
&#8211;)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>declare @hr int, @mi int, @AnyConstantDate datetime, @start datetime, @stop datetime<br />
set @hr = 0<br />
set @mi = 0<br />
set @AnyConstantDate = &#8217;20 apr 2011&#8242;&#8211; this can be any value but it needs to remain CONTANT<br />
&#8211;set @AnyConstantDate = dateadd(day, 0 ,datediff(day,0, @AnyConstantDate)) &#8212; strip offf the timestamp (if any) for this logic to work</p>
<p>&#8211; Initialize the values<br />
set @start =  @AnyConstantDate &#8212; Default time is 00:00:00<br />
&#8211;set @stop = dateadd(ss, 59, dateadd(mi, 29, @start)) &#8212; Elapse first half an hour by adding 29 minutes and 59 seconds</p>
<p>set @stop = dateadd(ss, 59, dateadd(mi, @Interval &#8211; 1, @start)) &#8212; Elapse first half an hour by adding 29 minutes and 59 seconds</p>
<p>&#8211; it is neccessary for the date in the expressions is stripped off time else it won&#8217;t work.<br />
&#8211; we just want to compare the date because the time part will keep changing.<br />
while (dateadd(day, 0 ,datediff(day,0, @stop))<br />
= dateadd(day, 0 ,datediff(day,0, @AnyConstantDate)) )  &#8212; the exact same CONSTANT date value needds to be used<br />
begin</p>
<p>insert into @timePeriods<br />
select convert(varchar(8), @start, 108)&#8217;StartTime&#8217;, &#8212; 108 is the hh:mi:ss format<br />
convert(varchar(8), @stop, 108) &#8216;StopTime&#8217;</p>
<p>set @start =  dateadd(mi, @Interval, @start) &#8212; Add half hour to the start time<br />
set @stop = dateadd(mi, @Interval, @stop) &#8212; Add half hour to the stop time</p>
<p>end</p>
<p>&#8211;select * from @timePeriods &#8212; To Test</p>
<p>return<br />
end</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=267&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/tsql-evenly-divide-24-hour-into-given-minutes-returns-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
		<item>
		<title>TSQL &#8211; Split Function &#8211; Feed in multiple values from a parameter &#8211; returns Table</title>
		<link>http://usamafahmed.wordpress.com/2011/10/20/tsql-split-function-feed-in-multiple-values-from-a-parameter-returns-table/</link>
		<comments>http://usamafahmed.wordpress.com/2011/10/20/tsql-split-function-feed-in-multiple-values-from-a-parameter-returns-table/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:32:39 +0000</pubDate>
		<dc:creator>Usama</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[defined]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[Multiple]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[returns]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[uder]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[Usama]]></category>
		<category><![CDATA[use]]></category>
		<category><![CDATA[values]]></category>

		<guid isPermaLink="false">http://usamafahmed.wordpress.com/?p=262</guid>
		<description><![CDATA[&#8211; I did not write this function and I do not take the credit for it. &#8211;This function is used to feed in values from the parameter seperated with  commas. Example: /* where @week in (select data from split(@WeekDayNumbers, &#8216;,&#8217;)) @WeekDayNumbers = &#8217;1,2,3,4,5,6,7&#8242; */ &#160; SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER FUNCTION [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=262&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>&#8211; I did not write this function and I do not take the credit for it.</p>
<p>&#8211;This function is used to feed in values from the parameter seperated with  commas. Example:</p>
<p>/*</p>
<p>where @week in (select data from split(@WeekDayNumbers, &#8216;,&#8217;))</p>
<p>@WeekDayNumbers = &#8217;1,2,3,4,5,6,7&#8242;</p>
<p>*/</p>
<p>&nbsp;</p>
<p>SET ANSI_NULLS ON<br />
GO<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
ALTER FUNCTION [dbo].[Split]<br />
(<br />
@RowData nvarchar(max),<br />
@SplitOn nvarchar(5)<br />
)<br />
RETURNS @RtnValue table &#8212; if the variable to be returned is mentioned then it does not need to mentioned again after the return key word<br />
(<br />
Data nvarchar(100)<br />
)<br />
AS<br />
BEGIN<br />
While (Charindex(@SplitOn,@RowData)&gt;0)<br />
Begin<br />
Insert Into @RtnValue (data)<br />
Select<br />
Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))</p>
<p>Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))<br />
End</p>
<p>Insert Into @RtnValue (data)<br />
Select Data = ltrim(rtrim(@RowData))</p>
<p>Return &#8212; this returns the current content of what is mentioned above (i.e. RETURNS @RtnValue table)<br />
END</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/usamafahmed.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/usamafahmed.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/usamafahmed.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/usamafahmed.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/usamafahmed.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/usamafahmed.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/usamafahmed.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/usamafahmed.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/usamafahmed.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/usamafahmed.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/usamafahmed.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/usamafahmed.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/usamafahmed.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/usamafahmed.wordpress.com/262/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=usamafahmed.wordpress.com&amp;blog=8627033&amp;post=262&amp;subd=usamafahmed&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://usamafahmed.wordpress.com/2011/10/20/tsql-split-function-feed-in-multiple-values-from-a-parameter-returns-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/27a35b46e9133acc1bee5249b2ea6e57?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">getusama</media:title>
		</media:content>
	</item>
	</channel>
</rss>
