<?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>C#, ASP.NET, SQL Server</title>
	<atom:link href="http://mycodelines.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mycodelines.wordpress.com</link>
	<description>(FAQ's + Code + Just about anything else...!)</description>
	<lastBuildDate>Tue, 11 Oct 2011 14:52:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mycodelines.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>C#, ASP.NET, SQL Server</title>
		<link>http://mycodelines.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mycodelines.wordpress.com/osd.xml" title="C#, ASP.NET, SQL Server" />
	<atom:link rel='hub' href='http://mycodelines.wordpress.com/?pushpress=hub'/>
		<item>
		<title>VS 2008 Solution Explorer Autohide</title>
		<link>http://mycodelines.wordpress.com/2009/09/12/vs-2008-solution-explorer-autohide/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/12/vs-2008-solution-explorer-autohide/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 12:09:07 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[Programming Tips & Tricks]]></category>
		<category><![CDATA[auto hide]]></category>
		<category><![CDATA[autohide]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Solution explorer]]></category>
		<category><![CDATA[toolbox settings]]></category>
		<category><![CDATA[Visual studio 2008]]></category>
		<category><![CDATA[VS 2008]]></category>
		<category><![CDATA[windows settings]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/2009/09/12/vs-2008-solution-explorer-autohide/</guid>
		<description><![CDATA[In Visual Studio 2008, I lost AutoHide feature on that window. when I right click on Solution explorer I see that AutoHide is disabled. How can I enable it.  2) Also I like all my autohide windows on left hand. how can I move right hand windows to left hand like resource view. Solution: Two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=310&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Visual Studio 2008,</p>
<p>I lost AutoHide feature on that window. when I right click on Solution explorer I see that AutoHide is disabled.</p>
<p>How can I enable it.</p>
<p> 2) Also I like all my autohide windows on left hand. how can I move right hand windows to left hand like resource view.</p>
<p>Solution:</p>
<p>Two things you can try:</p>
<p>1. Window-&gt;ResetWindow Layout</p>
<p>2. Tools-&gt;Import and Export Settings&#8230; Reset All Settings (Whether you save the current settings or not is your choice).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/310/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=310&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/12/vs-2008-solution-explorer-autohide/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>Memory Leak in CLR</title>
		<link>http://mycodelines.wordpress.com/2009/09/05/memory-leak-in-clr/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/05/memory-leak-in-clr/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 06:33:50 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CLR]]></category>
		<category><![CDATA[Dispose]]></category>
		<category><![CDATA[Finalize]]></category>
		<category><![CDATA[finally]]></category>
		<category><![CDATA[garbage collector]]></category>
		<category><![CDATA[GC]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[memory leak]]></category>
		<category><![CDATA[using]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=307</guid>
		<description><![CDATA[Definition of memory leak A memory leak occurs when memory is allocated in a program and is never returned to the operating system, even though the program does not use the memory any longer. The following are the four basic types of memory leaks: In a manually managed memory environment: Memory is dynamically allocated and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=307&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 id="tocHeadRef">Definition of memory leak</h3>
<p>A memory leak occurs when memory is allocated in a program and is never returned to the operating system, even though the program does not use the memory any longer. The following are the four basic types of memory leaks:</p>
<ul>
<li>In a manually managed memory environment: Memory is dynamically allocated and referenced by a pointer. The pointer is erased before the memory is freed. After the pointer is erased, the memory can no longer be accessed and therefore cannot be freed.</li>
<li>In a dynamically managed memory environment: Memory is disposed of but never collected, because a reference to the object is still active. Because a reference to the object is still active, the garbage collector never collects that memory. This can occur with a reference that is set by the system or the program.</li>
<li>In a dynamically managed memory environment: The garbage collector can collect and free the memory but never returns it to the operating system. This occurs when the garbage collector cannot move the objects that are still in use to one portion of the memory and free the rest.</li>
<li>In any memory environment: Poor memory management can result when many large objects are declared and never permitted to leave scope. As a result, memory is used and never freed.</li>
</ul>
<p><strong>When it occurs?</strong></p>
<p>Because of the garbage collection package that is implemented in the Microsoft .NET Framework, it is not possible to have a memory leak in managed code. This suggests two questions: How then can a memory leak occur? Why does it appear that you have a memory leak?</p>
<p>A memory leak can occur in a .NET Framework application when you use unmanaged code as part of the application. This unmanaged code can leak memory, and the .NET Framework runtime cannot address that problem.</p>
<p>Additionally, a project may only appear to have a memory leak. This condition can occur if many large objects (such as DataTable objects) are declared and then added to a collection (such as a DataSet). The resources that these objects own may never be released, and the resources are left alive for the whole run of the program. This appears to be a leak, but actually it is just a symptom of the way that memory is being allocated in the program.</p>
<p>If a collection is declared at the global level of the program, and objects are declared throughout the program and added to that collection, this means that even though the objects are no longer in scope, the objects remain alive because they are still being referenced.</p>
<p>Each time that this occurs, the amount of memory that the program is using increases. The memory does not decrease until the end of the program or the release of the objects from the collection. When you watch the program on a performance monitor, this appears to be a memory leak, but it is not. The program still has control over the memory but has chosen not to release it. The fact that the program still has control prevents this from being a memory leak, but the fact that the program keeps increasing the amount of memory used can make it appear to be a memory leak.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/307/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/307/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/307/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=307&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/05/memory-leak-in-clr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>ISNULL vs. COALESCE</title>
		<link>http://mycodelines.wordpress.com/2009/09/05/isnull-vs-coalesce/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/05/isnull-vs-coalesce/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 05:41:57 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[RDBMS Concepts]]></category>
		<category><![CDATA[SQL Server FAQ's]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[COALESCE]]></category>
		<category><![CDATA[ISNULL]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=305</guid>
		<description><![CDATA[ISNULL() ISNULL is a TSQL Function which is built into SQL Server. It is NOT a function defined by ANSI-92 &#8211; rather it is a feature which Microsoft has elected to include in TSQL in addition to the ANSI SQL standard. ISNULL() accepts two parameters. The first is evaluated, and if the value is null, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=305&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h6>ISNULL()</h6>
<p>ISNULL is a TSQL Function which is built into SQL Server. It is NOT a function defined by <a href="http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt">ANSI-92</a> &#8211; rather it is a feature which Microsoft has elected to include in TSQL in addition to the ANSI SQL standard.</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/ms184325.aspx">ISNULL()</a> accepts two parameters. The first is evaluated, and if the value is null, the second value is returned (regardless of whether or not it is null). The following queries will return the second parameter in both cases:</p>
<blockquote>
<pre>SELECT ISNULL(NULL, 1)
--Returns 1
SELECT ISNULL(NULL, NULL)
--Returns NULL</pre>
</blockquote>
<p><a name="COALESCE_Definition"></a></p>
<h6>COALESCE()</h6>
<p>COALESCE() is a TSQL function which, like ISNULL, is built into SQL Server. Unlike ISNULL, COALESCE is also a part of the <a href="http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt">ANSI-92</a> SQL Standard. Coalesce returns the first non-null expression in a list of expressions. The list can contain two or more items, and each item can be of a different data type. The following are valid examples of COALESCE:</p>
<blockquote>
<pre>SELECT COALESCE(NULL, 1)
--Returns 1

SELECT COALESCE(NULL, 3, NULL, 1)
--Returns 3</pre>
</blockquote>
<h6>ISNULL vs. COALESCE</h6>
<p>Whenever multiple methods exist for addressing a single problem, the inevitable question is: which method is better? There are a few differences between the two functions which make COALESCE come out on top more often than not:<br />
- COALESCE is ANSI-92 compliant. In the event that you need to port your code to another RDBMS, COALESCE will not require rework.<br />
- COALESCE accepts greater than two expressions, whereas ISNULL accepts only two. In order to compare three expressions with ISNULL, you would have to nest expressions:<br />
<span>SELECT ISNULL(ISNULL(Col1, Col2), Col3)</span><br />
- ISNULL constrains the result of a comparison of parameterrs to the datatype of the first value. For example, the following query will produce some often undesirable results using ISNULL, however it will behave as expected with COALESCE:</p>
<pre>DECLARE @Field1 char(3), @Field2 char(50)
SET @Field2 = 'Some Long String'

SELECT ISNULL(@Field1, @Field2)
--Returns 'Som'
SELECT COALESCE(@Field1, @Field2)
--Returns 'Some Long String'</pre>
<p><strong>Note:</strong> In other situations, COALESCE will produce <em>unexpected</em> results. COALESCE by nature promotes it&#8217;s arguments to the highest datatype among compatable arguments (arguments which are not explicitly case, and which aren&#8217;t compatable, will of course throw an error). When using COALESCE on an integer and a datetime, in that order, COALESCE will cast the integer as a datetime.</p>
<blockquote><p>For example:<br />
<span>SELECT COALESCE(5, GETDATE())</span><br />
Will not return 5, it will return 1900-01-06 00:00:00.000 (5 as a datetime).<span id="_marker"> </span></p></blockquote>
<h6>ISNULL vs. COALESCE</h6>
<p>Whenever multiple methods exist for addressing a single problem, the inevitable question is: which method is better? There are a few differences between the two functions which make COALESCE come out on top more often than not:<br />
- COALESCE is ANSI-92 compliant. In the event that you need to port your code to another RDBMS, COALESCE will not require rework.<br />
- COALESCE accepts greater than two expressions, whereas ISNULL accepts only two. In order to compare three expressions with ISNULL, you would have to nest expressions:<br />
<span class="codeInline">SELECT ISNULL(ISNULL(Col1, Col2), Col3)</span><br />
- ISNULL constrains the result of a comparison of parameterrs to the datatype of the first value. For example, the following query will produce some often undesirable results using ISNULL, however it will behave as expected with COALESCE:</p>
<blockquote>
<pre>DECLARE @Field1 char(3), @Field2 char(50)
SET @Field2 = 'Some Long String'

SELECT ISNULL(@Field1, @Field2)
--Returns 'Som'
SELECT COALESCE(@Field1, @Field2)
--Returns 'Some Long String'</pre>
</blockquote>
<p><strong>Note:</strong> In other situations, COALESCE will produce <em>unexpected</em> results. COALESCE by nature promotes it&#8217;s arguments to the highest datatype among compatable arguments (arguments which are not explicitly case, and which aren&#8217;t compatable, will of course throw an error). When using COALESCE on an integer and a datetime, in that order, COALESCE will cast the integer as a datetime.</p>
<blockquote><p> For example:<br />
<span class="codeInline">SELECT COALESCE(5, GETDATE())</span><br />
Will not return 5, it will return 1900-01-06 00:00:00.000 (5 as a datetime).</p></blockquote>
<pre> 
source:
 <a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Home">http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=ISNULL_COALESCE&amp;referringTitle=Homeb</a></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=305&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/05/isnull-vs-coalesce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>Finding Duplicates in a Table</title>
		<link>http://mycodelines.wordpress.com/2009/09/05/finding-duplicates-in-a-table/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/05/finding-duplicates-in-a-table/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 05:30:01 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[RDBMS Concepts]]></category>
		<category><![CDATA[SQL Server FAQ's]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[duplicate rows]]></category>
		<category><![CDATA[duplicate values]]></category>
		<category><![CDATA[find duplicates]]></category>
		<category><![CDATA[occurences]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sql table]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=301</guid>
		<description><![CDATA[Here&#8217;s a handy query for finding duplicates in a table. Suppose you want to find all email addresses in a table that exist more than once: SELECT email, COUNT(email) AS NumOccurrences FROM users GROUP BY email HAVING ( COUNT(email) &#62; 1 ) You could also use this technique to find rows that occur exactly once: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=301&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a handy query for finding duplicates in a table. Suppose you want to find all email addresses in a table that exist more than once:</p>
<pre>SELECT email,
 COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) &gt; 1 )</pre>
<p>You could also use this technique to find rows that occur exactly once:</p>
<pre>SELECT email
FROM users
GROUP BY email
HAVING ( COUNT(email) = 1 )</pre>
<blockquote>
<pre>For further reading:
<a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;139444">http://support.microsoft.com/default.aspx?scid=kb;en-us;139444</a>
<a href="http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=DuplicateRows&amp;referringTitle=Home">http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=DuplicateRows&amp;referringTitle=Home</a></pre>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/301/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/301/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/301/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=301&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/05/finding-duplicates-in-a-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>@@IDENTITY And SCOPE_IDENTITY()</title>
		<link>http://mycodelines.wordpress.com/2009/09/02/identity-and-scope_identity/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/02/identity-and-scope_identity/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 08:13:20 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[RDBMS Concepts]]></category>
		<category><![CDATA[SQL Server FAQ's]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[@@IDENTITY]]></category>
		<category><![CDATA[IDENT_CURRENT]]></category>
		<category><![CDATA[SCOPE_IDENTITY()]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=298</guid>
		<description><![CDATA[SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY are similar functions because they return values that are inserted into identity columns. IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the value generated for a specific table in any session and any scope. SCOPE_IDENTITY and @@IDENTITY return the last identity values [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=298&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY are similar functions because they return values that are inserted into identity columns.</p>
<p>IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the value generated for a specific table in any session and any scope.</p>
<p>SCOPE_IDENTITY and @@IDENTITY return the last identity values that are generated in any table in the current session. However, SCOPE_IDENTITY returns values inserted only within the current scope; @@IDENTITY is not limited to a specific scope.</p>
<p>For example, there are two tables, <strong>T1</strong> and <strong>T2</strong>, and an INSERT trigger is defined on <strong>T1</strong>. When a row is inserted to <strong>T1</strong>, the trigger fires and inserts a row in <strong>T2</strong>. This scenario illustrates two scopes: the insert on <strong>T1</strong>, and the insert on <strong>T2</strong> by the trigger.</p>
<p>Assuming that both <strong>T1</strong> and <strong>T2</strong> have identity columns, @@IDENTITY and SCOPE_IDENTITY will return different values at the end of an INSERT statement on <strong>T1</strong>. @@IDENTITY will return the last identity column value inserted across any scope in the current session. This is the value inserted in <strong>T2</strong>. SCOPE_IDENTITY() will return the IDENTITY value inserted in <strong>T1</strong>. This was the last insert that occurred in the same scope. The SCOPE_IDENTITY() function will return the null value if the function is invoked before any INSERT statements into an identity column occur in the scope.</p>
<p>Failed statements and transactions can change the current identity for a table and create gaps in the identity column values. The identity value is never rolled back even though the transaction that tried to insert the value into the table is not committed. For example, if an INSERT statement fails because of an IGNORE_DUP_KEY violation, the current identity value for the table is still incremented.</p>
<p><em><strong>Source: </strong></em><a href="http://msdn.microsoft.com/en-us/library/ms190315.aspx"><em>http://msdn.microsoft.com/en-us/library/ms190315.aspx</em></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=298&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/02/identity-and-scope_identity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>List All Database Objects in SQL Server</title>
		<link>http://mycodelines.wordpress.com/2009/09/02/list-all-database-objects-in-sql-server/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/02/list-all-database-objects-in-sql-server/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 05:52:04 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[RDBMS Concepts]]></category>
		<category><![CDATA[SQL Server FAQ's]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[information_schema.Tables]]></category>
		<category><![CDATA[procedures]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sys.Tables]]></category>
		<category><![CDATA[syscolumns]]></category>
		<category><![CDATA[sysobjects]]></category>
		<category><![CDATA[systypes]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=295</guid>
		<description><![CDATA[Below statemnent will list all tables int he current database. USE YourDBName GO 1) SELECT * FROM sys.Tables 2) SELECT    * FROM  information_schema.Tables Also, sysobjects, syscolumns and systypes are the database objects that we would be using here. Sysobjects contains information about each object in the database. this includes the object name, the user [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=295&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;"><span style="color:#000000;">Below statemnent will list all tables int he current database.</span></p>
<p><span style="color:#000000;"><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">YourDBName<br />
GO </span></code></span></p>
<p><span style="color:#000000;"><code style="font-size:12px;"><span style="color:blue;">1) SELECT </span><span style="color:gray;">* </span><span style="color:blue;">FROM </span><span style="color:black;">sys.Tables </span></code></span></p>
<p><font size="2" color="#0000ff"><font size="2" color="#0000ff">2) SELECT </p>
<p></font></font></span><font size="2" color="#0000ff"> </p>
<p></font></span></p>
<p><span style="color:#808080;font-size:x-small;"><span style="color:#808080;font-size:x-small;">* </span></span><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;">FROM  </span></span><span style="color:#008000;font-size:x-small;"><span style="color:#008000;font-size:x-small;">information_schema.Tables</span></span></p>
<p>Also,<strong> sysobjects</strong>, <strong>syscolumns</strong> and <strong>systypes</strong> are the database objects that we would be using here.</p>
<p><strong>Sysobjects</strong> contains information about each object in the database. this includes the object name, the user id of the user who created this object and many other useful information.</p>
<p>      <em>select * from sysobjects;</em></p>
<p>The most useful column in this table is the <strong>type</strong> column. This column signifies what type of object is in the returned rowset. specifying</p>
<p><em>      select * from sysobjects where type = &#8216;u&#8217;</em> ;</p>
<p>will return the list of tables on the current database. Here&#8217;s a list of possible values for xtype:</p>
<ul>
<li>C : CHECK constraint</li>
<li>D : Default or DEFAULT constraint</li>
<li>F : FOREIGN KEY constraint</li>
<li>L : Log</li>
<li>P : Stored procedure</li>
<li>PK : PRIMARY KEY constraint (type is K)</li>
<li>RF : Replication filter stored procedure</li>
<li>S : System tables</li>
<li>TR : Triggers</li>
<li>U : User table</li>
<li>UQ : UNIQUE constraint (type is K)</li>
<li>V : Views</li>
<li>X : Extended stored procedure</li>
<li>TF : Functions</li>
</ul>
<p>You can use <strong>syscolumns</strong>  to retrieve columns on the database. doing</p>
<p>      <em>select * from syscolumns</em></p>
<p>would return a result containing column information which you can use to determine the scale, data type, precision and etc. The <strong>xtype</strong> on the <strong>syscolumns</strong> table acts differently from the sysobjects. the xtype column here represents the datatatype of that column. running this script:</p>
<p>   <em>select * from syscolumns where xtype = 167;</em></p>
<p>will return all columns that has a datatype of varchar. heres a list of possible values for this xtype column:</p>
<p>34 image<br />
35 text<br />
36 uniqueidentifier<br />
48 tinyint<br />
52 smallint<br />
56 int<br />
58 smalldatetime<br />
59 real<br />
60 money<br />
61 datetime<br />
62 float<br />
98 sql_variant<br />
99 ntext<br />
104 bit<br />
106 decimal<br />
108 numeric<br />
122 smallmoney<br />
127 bigint<br />
165 varbinary<br />
167 varchar<br />
173 binary<br />
175 char<br />
189 timestamp<br />
231 nvarchar<br />
239 nchar<br />
241 xml<br />
231 sysname</p>
<p> </p>
<p>I got this xtypes by running : <em>select xtype, name from systypes;</em> which basically contains a list of available sql datatypes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/295/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=295&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/02/list-all-database-objects-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>Difference between Function and Stored procedure</title>
		<link>http://mycodelines.wordpress.com/2009/09/01/difference-between-function-and-stored-procedure/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/01/difference-between-function-and-stored-procedure/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 11:22:51 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[RDBMS Concepts]]></category>
		<category><![CDATA[SQL Server FAQ's]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[stored procedure]]></category>
		<category><![CDATA[user defined functions]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=292</guid>
		<description><![CDATA[The following are the differences between a User Defined Function and a Stored Procedure in SQL Server   Stored Procedure support deffered name resolution where as functions do not support deffered name resolution. User Defined Function can be used in a select statement where as you cannot use a stored procedure in a select statement. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=292&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<table border="0" width="100%">
<tbody>
<tr>
<td>The following are the differences between a User Defined Function and a Stored Procedure in SQL Server</p>
<p> </td>
</tr>
<tr>
<td>
<ol>
<li>Stored Procedure support deffered name resolution where as functions do not support deffered name resolution.</li>
<li>User Defined Function can be used in a select statement where as you cannot use a stored procedure in a select statement.</li>
<li>UDF&#8217;s cannot return Image, Text where as a StoredProcedure can return any datatype.</li>
<li>In general User Defined Functions are used for computations where as Stored Procedures are used for performing business logic.</li>
<li>UDF should return a value where as Stored Procedure need not.</li>
<li>User Defined Functions accept lesser number of input parameters than Stored Procedures. UDF can have upto 1023 input parameters where as a Stored Procedure can have upto 21000 input parameters.</li>
<li>You cannot use non-deterministic built-in functions in UDF&#8217;s. For example functions like GETDATE() etc can not be used in UDFs, but can be used in Stored Procedures.</li>
<li>Temporary Tables can not be used in a UDF where as a StoredProcedure can use Temporary Tables.</li>
<li>UDF can not Execute Dynamic SQL where as a Stored Procedure can execute Dynamic SQL.</li>
<li>User Defined Function does not support error handling where as Stored Procedure support error handling. RAISEERROR or @@ERROR are not allowed in UDFs.</li>
</ol>
</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/292/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=292&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/01/difference-between-function-and-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>What is Self Join?</title>
		<link>http://mycodelines.wordpress.com/2009/09/01/what-is-self-join/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/01/what-is-self-join/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 11:20:26 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[RDBMS Concepts]]></category>
		<category><![CDATA[SQL Server FAQ's]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[COALESCE]]></category>
		<category><![CDATA[inner join]]></category>
		<category><![CDATA[joins]]></category>
		<category><![CDATA[left outer]]></category>
		<category><![CDATA[outer join]]></category>
		<category><![CDATA[right outer]]></category>
		<category><![CDATA[self join]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=284</guid>
		<description><![CDATA[Use the script below to create Employee Table and populate it with some sample data. We will be using Employee Table to understand Self Join. CREATE TABLE EMPLOYEE( [EMPLOYEEID] INT PRIMARY KEY, [NAME] NVARCHAR(50), [MANAGERID] INT ) GO INSERT INTO EMPLOYEE VALUES(101,&#8217;Mary&#8217;,102) INSERT INTO EMPLOYEE VALUES(102,&#8217;Ravi&#8217;,NULL) INSERT INTO EMPLOYEE VALUES(103,&#8217;Raj&#8217;,102) INSERT INTO EMPLOYEE VALUES(104,&#8217;Pete&#8217;,103) INSERT [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=284&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<table border="0" width="100%">
<tbody>
<tr>
<td>Use the script below to create Employee Table and populate it with some sample data. We will be using Employee Table to understand Self Join.</td>
</tr>
<tr>
<td>CREATE TABLE EMPLOYEE(</p>
<p>[EMPLOYEEID] INT PRIMARY KEY,</p>
<p>[NAME] NVARCHAR(50),</p>
<p>[MANAGERID] INT</p>
<p>)</p>
<p>GO</p>
<p>INSERT INTO EMPLOYEE VALUES(101,&#8217;Mary&#8217;,102)</p>
<p>INSERT INTO EMPLOYEE VALUES(102,&#8217;Ravi&#8217;,NULL)</p>
<p>INSERT INTO EMPLOYEE VALUES(103,&#8217;Raj&#8217;,102)</p>
<p>INSERT INTO EMPLOYEE VALUES(104,&#8217;Pete&#8217;,103)</p>
<p>INSERT INTO EMPLOYEE VALUES(105,&#8217;Prasad&#8217;,103)</p>
<p>INSERT INTO EMPLOYEE VALUES(106,&#8217;Ben&#8217;,103)</p>
<p>GO</td>
</tr>
<tr>
<td>
We use Self Join, if we have a table that references itself. For example, In the Employee Table below MANAGERID column references EMPLOYEEID column. So the table is said to referencing itself. This is the right scenario where we can use Self Join. Now I want to write a query that will give me the list of all Employee Names and their respective Manager Names. In order to achieve this I can use Self Join. In the Table below,Raj is the manager for Pete,Prasad and Ben. Ravi is the manager for Raj and Mary. Ravi does not have a manager as he is the president of the Company.</p>
<p> </td>
</tr>
</tbody>
</table>
<table border="0" width="100%">
<tbody>
<tr>
<td><img class="aligncenter size-full wp-image-288" title="Employee1" src="http://mycodelines.files.wordpress.com/2009/09/employee11.gif?w=354&#038;h=192" alt="Employee1" width="354" height="192" /></p>
<p>The query below is an example of Self Join. Both E1 and E2 refer to the same Employee Table. In this query we are joining the Employee Table with itself.</td>
</tr>
<tr>
<td>SELECT E1.[NAME],E2.[NAME] AS [MANAGER NAME]</p>
<p>FROM EMPLOYEE E1</p>
<p>INNER JOIN EMPLOYEE E2</p>
<p>ON E2.EMPLOYEEID =E1.MANAGERID</td>
</tr>
</tbody>
</table>
<p><img title="SelfJoin" src="http://mycodelines.files.wordpress.com/2009/09/selfjoin.gif?w=292&#038;h=176" alt="SelfJoin" width="292" height="176" /></p>
<p>This is because Ravi does not have a Manager. MANAGERID column for Ravi is NULL. If we want to get all the rows then we can use LEFT OUTER JOIN as shown below.</p>
<table border="0" width="100%">
<tbody>
<tr>
<td>SELECT E1.[NAME],E2.[NAME] AS [MANAGER NAME]</p>
<p>FROM EMPLOYEE E1</p>
<p>LEFT OUTER JOIN EMPLOYEE E2</p>
<p>ON E2.EMPLOYEEID =E1.MANAGERID</td>
</tr>
<tr>
<td>If we execute the above query we get all the rows, including the row that has a null value in the MANAGERID column. The results are shown below. The MANAGERNAME for 2nd record is NULL as Ravi does not have a Manager.</td>
</tr>
</tbody>
</table>
<table border="0" width="100%">
<tbody>
<tr>
<td><img class="aligncenter size-full wp-image-289" title="SelfJoin1" src="http://mycodelines.files.wordpress.com/2009/09/selfjoin1.gif?w=287&#038;h=187" alt="SelfJoin1" width="287" height="187" /></p>
<p>Let us now slightly modify the above query using COALESCE as shown below.</td>
</tr>
<tr>
<td>SELECT E1.[NAME],COALESCE(E2.[NAME],&#8217;No Manager&#8217;) as [MANAGER NAME]</p>
<p>FROM EMPLOYEE E1</p>
<p>LEFT JOIN EMPLOYEE E2</p>
<p>ON E2.EMPLOYEEID =E1.MANAGERID</td>
</tr>
</tbody>
</table>
<p> If we execute the above query the output will be as shown in the image below. This is how COALESCE can be used.</p>
<p><img class="aligncenter size-full wp-image-290" title="SelfJoin2" src="http://mycodelines.files.wordpress.com/2009/09/selfjoin2.gif?w=326&#038;h=192" alt="SelfJoin2" width="326" height="192" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=284&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/01/what-is-self-join/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>

		<media:content url="http://mycodelines.files.wordpress.com/2009/09/employee11.gif" medium="image">
			<media:title type="html">Employee1</media:title>
		</media:content>

		<media:content url="http://mycodelines.files.wordpress.com/2009/09/selfjoin.gif" medium="image">
			<media:title type="html">SelfJoin</media:title>
		</media:content>

		<media:content url="http://mycodelines.files.wordpress.com/2009/09/selfjoin1.gif" medium="image">
			<media:title type="html">SelfJoin1</media:title>
		</media:content>

		<media:content url="http://mycodelines.files.wordpress.com/2009/09/selfjoin2.gif" medium="image">
			<media:title type="html">SelfJoin2</media:title>
		</media:content>
	</item>
		<item>
		<title>In which scenario we use Abstract Classes and Interfaces</title>
		<link>http://mycodelines.wordpress.com/2009/09/01/in-which-scenario-we-use-abstract-classes-and-interfaces/</link>
		<comments>http://mycodelines.wordpress.com/2009/09/01/in-which-scenario-we-use-abstract-classes-and-interfaces/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 10:16:58 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[C# Concepts]]></category>
		<category><![CDATA[C# FAQ's]]></category>
		<category><![CDATA[abstract]]></category>
		<category><![CDATA[Abstract Class]]></category>
		<category><![CDATA[abstract classes in C#]]></category>
		<category><![CDATA[abstraction]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[override]]></category>
		<category><![CDATA[virtual]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=280</guid>
		<description><![CDATA[Interface: &#8211;&#62; If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces. For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=280&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong><span style="text-decoration:underline;">Interface:</span></strong></p>
<p><span>&#8211;&gt; If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use <span>interfaces</span>. </span></p>
<p>For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods like Drive(). All child classes like Car Scooter AirPlane SolarCar etc. should derive from this base interface but provide a seperate implementation of the methods and properties exposed by Vehicle.</p>
<p><span>&#8211;&gt; If you want your child classes to implement multiple unrelated functionalities in short multiple inheritance use <span>interfaces</span>. </span></p>
<p><span>For e.g. if you are implementing a class called SpaceShip that has to have functionalities from a Vehicle as well as that from a UFO then make both Vehicle and UFO as <span>interfaces</span> and then create a class SpaceShip that implements both Vehicle and UFO .</span></p>
<p><strong><span style="text-decoration:underline;">Abstract Classes</span></strong></p>
<p>&#8211;&gt; When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.</p>
<p><span>For e.g. again take the example of the Vehicle class above. If we want all classes deriving from Vehicle to implement the Drive() method in a fixed way whereas the other methods can be overridden by child classes. In such a scenario we implement the Vehicle class as an <span>abstract class</span> with an implementation of Drive while leave the other methods / properties as abstract so they could be overridden by child classes.</span></p>
<p><span>&#8211;&gt; The purpose of an <span>abstract class</span> is to provide a common definition of a base class that multiple derived classes can share. </span></p>
<p><span>For example a class library may define an <span>abstract class</span><span> that is used as a parameter to many of its functions and require programmers using that library to provide their own implementation of the class by creating a derived class.</span></span></p>
<h3>Use an abstract class</h3>
<ul>
<li>When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. ( COM was designed around interfaces.)</li>
</ul>
<ul>
<li>Use an abstract class to define a common base class for a family of types.</li>
</ul>
<ul>
<li>Use an abstract class to provide default behavior.</li>
</ul>
<ul>
<li>Subclass only a base class in a hierarchy to which the class logically belongs.</li>
</ul>
<p> </p>
<h3>Use an interface</h3>
<ul>
<li>When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.</li>
</ul>
<ul>
<li>Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.</li>
</ul>
<ul>
<li>Use an interface to design a polymorphic hierarchy for value types.</li>
</ul>
<ul>
<li>Use an interface when an immutable contract is really intended.</li>
</ul>
<ul>
<li>A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality.</li>
</ul>
<p><span><span> </span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=280&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/09/01/in-which-scenario-we-use-abstract-classes-and-interfaces/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
		<item>
		<title>Difference between UNIQUE constraint and PRIMARY key</title>
		<link>http://mycodelines.wordpress.com/2009/08/26/difference-between-unique-constraint-and-primary-key/</link>
		<comments>http://mycodelines.wordpress.com/2009/08/26/difference-between-unique-constraint-and-primary-key/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 09:57:47 +0000</pubDate>
		<dc:creator>Lakshmi Sravanthi Chowdam</dc:creator>
				<category><![CDATA[RDBMS Concepts]]></category>
		<category><![CDATA[SQL Server FAQ's]]></category>
		<category><![CDATA[constraints]]></category>
		<category><![CDATA[Primary constraint]]></category>
		<category><![CDATA[Primary Key]]></category>
		<category><![CDATA[unique]]></category>
		<category><![CDATA[unique constraint]]></category>

		<guid isPermaLink="false">http://mycodelines.wordpress.com/?p=277</guid>
		<description><![CDATA[A UNIQUE constraint is similar to PRIMARY key, but you can have more than one UNIQUE constraint per table. When you declare a UNIQUE constraint, SQL Server creates a UNIQUE index to speed up the process of searching for duplicates. In this case the index defaults to NONCLUSTERED index, because you can have only one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=277&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A UNIQUE constraint is similar to PRIMARY key, but you can have more than one UNIQUE constraint per table.</p>
<p>When you declare a UNIQUE constraint, SQL Server creates a UNIQUE index to speed up the process of searching for duplicates. In this case the index defaults to NONCLUSTERED index, because you can have only one CLUSTERED index per table.</p>
<p>* The number of UNIQUE constraints per table is limited by the number of indexes on the table i.e 249 NONCLUSTERED index and one possible CLUSTERED index.</p>
<p>Contrary to PRIMARY key UNIQUE constraints can accept NULL but just once. If the constraint is defined in a combination of fields, then every field can accept NULL and can have some values on them, as long as the combination values is unique.</p>
<p>Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn&#8217;t allow NULLs, but unique key allows one NULL only.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mycodelines.wordpress.com/277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mycodelines.wordpress.com/277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mycodelines.wordpress.com/277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mycodelines.wordpress.com/277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mycodelines.wordpress.com/277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mycodelines.wordpress.com/277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mycodelines.wordpress.com/277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mycodelines.wordpress.com/277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mycodelines.wordpress.com/277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mycodelines.wordpress.com/277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mycodelines.wordpress.com/277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mycodelines.wordpress.com/277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mycodelines.wordpress.com/277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mycodelines.wordpress.com/277/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mycodelines.wordpress.com&amp;blog=5629096&amp;post=277&amp;subd=mycodelines&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mycodelines.wordpress.com/2009/08/26/difference-between-unique-constraint-and-primary-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/288f66c081902691113152e3f6bd6895?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sravanthiwinner</media:title>
		</media:content>
	</item>
	</channel>
</rss>
