<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DkMCRHg7fSp7ImA9WhVTEkk.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713</id><updated>2012-02-26T00:21:05.605-08:00</updated><category term="selfjoin in sql server" /><category term="Full Outer Join" /><category term="dot net" /><category term="Right Outer Join with an example" /><category term="What is the use of COALESCE in SQL Server" /><category term="difference between a User Defined Function and a Stored Procedure in SQL Server" /><category term="sql server interview questions" /><category term="Advantages of stored procedures" /><category term="table scan" /><category term="example" /><category term="Self Join" /><category term="Full Outer Join in SQL Server with an example" /><category term="Self Join with an example" /><category term="SQL Server Interview Questions on Indexes" /><category term="indexed views" /><category term="Delete from tables involved in a SQL Join" /><category term=".net developers" /><category term="difference between a UDF and an SP in SQL Server" /><category term="SQL Server Interview Questions on triggers" /><category term="self join in sql server" /><category term="advantages of using views" /><category term="Inner Join with example" /><category term="Left Join with an example" /><category term="difference between Having and Where clause in sql server" /><category term="joins" /><category term="Difference between Index Scan and Index Seek" /><category term="cross join" /><category term="Full Outer Join in SQL Server" /><category term="SQL Server Interview Questions on Temporary Tables" /><category term="selfjoin" /><category term="Left Join in SQL Server" /><category term="difference between a Temporary Table and a Table Variable" /><category term="materialized views" /><category term="dotnet" /><category term="Right Join in sql server" /><category term="SQL Server Interview Questions by topic" /><title>SQL Server Interview Questions</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://venkatsqlinterview.blogspot.com/" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/blogspot/YpXCj" /><feedburner:info uri="blogspot/ypxcj" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CE4ER388fyp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-7302948850774795479</id><published>2011-07-20T12:42:00.000-07:00</published><updated>2012-01-22T09:21:46.177-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:21:46.177-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Advantages of stored procedures" /><title>Advantages of stored procedures</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="width: 550px; word-wrap: break-word;"&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;This is a very common sql server interview question. There are several advantages of using stored procedures over adhoc queries, as listed below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;1. &lt;strong&gt;Better Performance&lt;/strong&gt; : Stored procedures are precompiled and hence run much faster than adhoc queries&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;2. &lt;strong&gt;Better Security &lt;/strong&gt;: Applications making use of dynamically built adhoc sql queries are highly &lt;div style="display:block;float:left;margin: 3px;"&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/div&gt;susceptible to sql injection attacks, where as Stored Procedures can avoid SQL injection attacks completely.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;3. &lt;strong&gt;Reduced Network Traffic&lt;/strong&gt;: Stored procedures can reduce network traffic to a very great extent when compared with adhoc sql queries. With stored procedures, you only need to send the name of the procedure between client and server. Imagine the amount of network bandwith that can be saved especially if the stored procedure contains 1000 to 2000 lines of SQL.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;4. &lt;strong&gt;Better Maintainance and Reusability&lt;/strong&gt;: Stored procedures can be used any where in the application. It is easier to maintain a stored procedure that is used on several pages as &lt;span style="color: black;"&gt;the&lt;/span&gt; modfifcations just need to be changed at one place where the stored procedure is defined. On the other hand, maintaining an adhoc sql query that's used on several pages is tedious and error prone, as we have to make modifications on each and every page.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;If you can think of any other advantage of using stored procedures, please contribute by submitting the form below.&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-7302948850774795479?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/L3EFr_qWQOsS4Fga7FgyrJAfTSA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L3EFr_qWQOsS4Fga7FgyrJAfTSA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/L3EFr_qWQOsS4Fga7FgyrJAfTSA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L3EFr_qWQOsS4Fga7FgyrJAfTSA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/tcuK5SlUbJk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/7302948850774795479/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/07/advantages-of-stored-procedures.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7302948850774795479?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7302948850774795479?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/tcuK5SlUbJk/advantages-of-stored-procedures.html" title="Advantages of stored procedures" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/07/advantages-of-stored-procedures.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQGQ3ozeip7ImA9WhRbEEk.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-7838646694453534407</id><published>2011-07-11T11:03:00.000-07:00</published><updated>2012-01-31T14:02:02.482-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-31T14:02:02.482-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Delete from tables involved in a SQL Join" /><title>Delete from tables involved in a SQL Join</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;br /&gt;
&lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;This question is not asked that often in an interview, but you may have to write a query to delete from tables that are involved in a SQL join in your day to day job routine as a SQL Developer. &lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Let me explain you the question first. Consider the &lt;strong&gt;Employees&lt;/strong&gt; and &lt;strong&gt;Departments &lt;/strong&gt;tables below. &lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;div style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="1" m$="true" src="http://2.bp.blogspot.com/-MzSIk45T5rU/Ths5i6FV_fI/AAAAAAAAAHg/0MAsPaMpGsw/s1600/EmployeeAndDept.png" /&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;I want you to write a query &lt;span style="color: black;"&gt;using&lt;/span&gt; joins which will give me the &lt;strong&gt;list of all HR Department employees&lt;/strong&gt;. The output should be as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="0" m$="true" src="http://4.bp.blogspot.com/-ah-T-JhqATM/Ths68R8yGtI/AAAAAAAAAHk/j48buWBaqms/s1600/JoinResult.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;strong&gt;To do this we will write a query using joins as shown below.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Select&lt;/span&gt; E.Name as [Employee Name],D.Name as [Department Name]&lt;br /&gt;
&lt;span style="color: blue;"&gt;from&lt;/span&gt; Employees E&lt;br /&gt;
&lt;span style="color: #444444;"&gt;Inner Join&lt;/span&gt; Departments D&lt;br /&gt;
&lt;span style="color: blue;"&gt;On&lt;/span&gt; E.DeptId = D.Id&lt;br /&gt;
&lt;span style="color: blue;"&gt;Where&lt;/span&gt; D.Name = 'HR'&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Now I want you to write a query, that &lt;strong&gt;deletes all the HR department employees&lt;/strong&gt;. To do this we have to join &lt;strong&gt;Employees &lt;/strong&gt;and &lt;strong&gt;Departments &lt;/strong&gt;tables and usually we will be tempted to write the query as shown below, but this query will not execute and will give a syntax error.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #cc0000; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Incorrect SQL Delete Query to delete from multiple tables invloved in a SQL join&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Delete&lt;/span&gt; &lt;span style="color: blue;"&gt;From&lt;/span&gt; Employees E&lt;br /&gt;
&lt;span style="color: #444444;"&gt;Inner Join&lt;/span&gt; Departments D&lt;br /&gt;
&lt;span style="color: blue;"&gt;On&lt;/span&gt; E.DeptId = D.Id&lt;br /&gt;
&lt;span style="color: blue;"&gt;Where&lt;/span&gt; D.Name = 'HR'&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #274e13; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;The query below shows the correct syntax for issuing a SQL delete that involves a SQL join.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Delete&lt;/span&gt; E From (Employees E&lt;br /&gt;
&lt;span style="color: #444444;"&gt;Inner Join&lt;/span&gt; Departments D&lt;br /&gt;
&lt;span style="color: blue;"&gt;On&lt;/span&gt; E.DeptId = D.Id&lt;br /&gt;
&lt;span style="color: blue;"&gt;and&lt;/span&gt; D.Name = 'HR')&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;The following syntax is also valid and has the same effect.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Delete&lt;/span&gt;&amp;nbsp;Employees &lt;span style="color: blue;"&gt;From&lt;/span&gt;&lt;br /&gt;
(&lt;br /&gt;
Employees &lt;span style="color: blue;"&gt;join&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;Departments&lt;br /&gt;
&lt;span style="color: blue;"&gt;on &lt;/span&gt;Employees.DeptId = Departments.Id&lt;br /&gt;
)&lt;br /&gt;
&lt;span style="color: blue;"&gt;where&amp;nbsp;&lt;/span&gt;Departments.Name = '&lt;span style="color: red;"&gt;HR&lt;/span&gt;'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;br /&gt;
&lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-7838646694453534407?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ugeqde3WAkWp61p6l5vhKYuyYKE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ugeqde3WAkWp61p6l5vhKYuyYKE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ugeqde3WAkWp61p6l5vhKYuyYKE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ugeqde3WAkWp61p6l5vhKYuyYKE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/HnnymMHQEiA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/7838646694453534407/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/07/delete-from-tables-involved-in-sql-join.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7838646694453534407?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7838646694453534407?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/HnnymMHQEiA/delete-from-tables-involved-in-sql-join.html" title="Delete from tables involved in a SQL Join" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-MzSIk45T5rU/Ths5i6FV_fI/AAAAAAAAAHg/0MAsPaMpGsw/s72-c/EmployeeAndDept.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/07/delete-from-tables-involved-in-sql-join.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUFQ34ycSp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-8671219134011705462</id><published>2011-07-09T02:18:00.000-07:00</published><updated>2012-01-22T09:26:52.099-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:26:52.099-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="difference between Having and Where clause in sql server" /><title>What is the difference between Having and Where clause</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Let us understand the difference between&amp;nbsp;&lt;strong&gt;HAVING&lt;/strong&gt; and &lt;strong&gt;WHERE&lt;/strong&gt; clause with an example. Consider the &lt;strong&gt;Employees&lt;/strong&gt; table below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Employee Table&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;img border="0" m$="true" src="http://1.bp.blogspot.com/-H3VWHNyH8tA/ThgZU_tpFLI/AAAAAAAAAHc/fOpfgBCUMKM/s1600/Employees.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Use the script below to create and populate the table, so you can follow along with the examples.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; [dbo].[Employees1]&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; [Id] [int] NOT NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; [Name] [nvarchar](50) NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; [Dept] [nvarchar](50) NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; [Gender] [nvarchar](50) NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; [Country] [nvarchar](50) NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; [Salary] [float] NULL,&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Data Inserttion Script:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(1,'John','IT','Male','UK',5000)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(2,'Mary','HR','Female','India',3000)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(3,'Todd','IT','Male','UK',3500)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(4,'Pam','HR','Female','India',4000)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(5,'Tatcher','Payroll','Male','USA',2000)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(6,'Sunil','IT','Male','USA',1400)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(7,'Hari','Payroll','Male','UK',2500)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(8,'Sunitha','HR','Female','India',4000)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(9,'Sneha','IT','Female','India',3000)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Insert into&lt;/span&gt; Employees Values(10,'Ruby','Payroll','Male','UK',4600)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;You can use &lt;strong&gt;HAVING&lt;/strong&gt; clause only when you use &lt;strong&gt;Group By &lt;/strong&gt;clause. The following query will give an error stating "Column 'Employees.Dept' is invalid in the HAVING clause because it is not contained in either an aggregate function or the &lt;strong&gt;GROUP BY&lt;/strong&gt; clause."&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Select &lt;/span&gt;* &lt;span style="color: blue;"&gt;from&lt;/span&gt; Employees &lt;span style="color: blue;"&gt;Having&lt;/span&gt; Dept=&lt;span style="color: red;"&gt;'IT'&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;So to filter the rows as they are selected from the table we use &lt;strong&gt;WHERE&lt;/strong&gt; clause as shown below &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Select&lt;/span&gt; * &lt;span style="color: blue;"&gt;from&lt;/span&gt; Employees &lt;span style="color: blue;"&gt;Where&lt;/span&gt; Dept=&lt;span style="color: red;"&gt;'IT'&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If I want to select, the toal number of employees in IT department I can write the query in 2 different ways as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;1. &lt;span style="color: blue;"&gt;Select&lt;/span&gt; Dept, &lt;span style="color: magenta;"&gt;COUNT(*)&lt;/span&gt; as Total &lt;span style="color: blue;"&gt;from&lt;/span&gt; Employees &lt;span style="color: blue;"&gt;Where&lt;/span&gt; Dept='IT' &lt;span style="color: blue;"&gt;Group By &lt;/span&gt;Dept&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;2. &lt;span style="color: blue;"&gt;Select&lt;/span&gt; Dept, &lt;span style="color: magenta;"&gt;COUNT(*)&lt;/span&gt; as Total &lt;span style="color: blue;"&gt;from&lt;/span&gt; Employees &lt;span style="color: blue;"&gt;Group By &lt;/span&gt;Dept &lt;span style="color: blue;"&gt;Having&lt;/span&gt; Dept='IT'&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The first query runs faster than the second query. This is because, in the first query we only select IT department records and then perform the count operation where as in the second query we perform the count on all the Department records and then select only the IT department and its count using the HAVING clause. As the second query has more records to process than the first query, it tends to be relatively slower.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;So, a WHERE clause is used in the select statement to filter the rows as they are retrieved from the database table. HAVING clause is used in the select statement in conjunction with the Group By clause, to filter the query results after they have been grouped.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you have spotted any errors or if you can improve this answer further, please feel free to do so by submitting the form below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-8671219134011705462?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/B--g0x1Z_43eMbyU03qSjAJwOq8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B--g0x1Z_43eMbyU03qSjAJwOq8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/B--g0x1Z_43eMbyU03qSjAJwOq8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B--g0x1Z_43eMbyU03qSjAJwOq8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/jEIEHy54avM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/8671219134011705462/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/07/what-is-difference-between-having-and.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8671219134011705462?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8671219134011705462?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/jEIEHy54avM/what-is-difference-between-having-and.html" title="What is the difference between Having and Where clause" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-H3VWHNyH8tA/ThgZU_tpFLI/AAAAAAAAAHc/fOpfgBCUMKM/s72-c/Employees.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/07/what-is-difference-between-having-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04MRX8_fSp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-8836101457368004341</id><published>2011-06-05T10:53:00.000-07:00</published><updated>2012-01-22T09:06:24.145-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:06:24.145-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><title>SQL Server Interview Questions Index</title><content type="html">&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions.html"&gt; Basic SQL Server Interview Questions &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/07/what-is-difference-between-having-and.html"&gt; What is the difference between Having and Where clause&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_2213.html"&gt; SQL Server Interview Questions on Temporary Tables &lt;/a&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
google_ad_host = "pub-1556223355139109";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on.html"&gt; SQL Server Interview Questions on Indexes - Part 1 &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_07.html"&gt; SQL Server Interview Questions on Indexes - Part 2 &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-temporary.html"&gt; What is the difference between a Temporary Table and a Table Variable &lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-use-of-coalesce-in-sql-server.html"&gt; What is the use of COALESCE in SQL Server &lt;/a&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
google_ad_host = "pub-1556223355139109";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_10.html"&gt; SQL Server Interview Questions on triggers &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-user-defined.html"&gt; Difference between User Defined Function and Stored Procedure &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views.html"&gt; SQL Server Interview Questions on Views - Part 1 &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views_16.html"&gt; SQL Server Interview Questions on Views - Part 2 &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt; Basic SQL Server Interview Questions on Joins &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html"&gt; Explain Inner Join with an example &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html"&gt; Explain Left Outer Join with an example &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/right-outer-join-with-example.html"&gt; Explain Right Outer Join with an example &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/full-outer-join-in-sql-server-with.html"&gt; Explain Full Outer Join with an example &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/self-join-with-example.html"&gt; Explain Self Join with an example &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/difference-between-index-scan-and-index.html"&gt; What is the difference between Index Scan and Index Seek &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/07/advantages-of-stored-procedures.html"&gt; What are the advantages of using stored procedures &lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-8836101457368004341?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/pUMsORkFzpvgxpYknsQyhQGNeIg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pUMsORkFzpvgxpYknsQyhQGNeIg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/pUMsORkFzpvgxpYknsQyhQGNeIg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pUMsORkFzpvgxpYknsQyhQGNeIg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/AboR94o-4Kg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/8836101457368004341/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/06/sql-server-interview-questions-index.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8836101457368004341?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8836101457368004341?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/AboR94o-4Kg/sql-server-interview-questions-index.html" title="SQL Server Interview Questions Index" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/06/sql-server-interview-questions-index.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4MQXg-eSp7ImA9WhZUEkQ.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-8572772108727889617</id><published>2011-06-05T10:51:00.001-07:00</published><updated>2011-06-05T11:19:40.651-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-05T11:19:40.651-07:00</app:edited><title>Search Results</title><content type="html">&lt;div id="cse-search-results"&gt;&lt;/div&gt;&lt;script type="text/javascript"&gt;
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 800;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;table style="border: 1px solid #0066CC;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="width: 180px;padding-top:1px;"&gt;&lt;span style="color: black; font-family: Arial; font-size: 8pt; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;HR Interview Questions&lt;/span&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="border-top:1px solid black; text-align:center;color: #0066CC; font-family: Arial; font-size: 9pt;" colspan="2"&gt;&lt;span style="color:Red"&gt;Didn't find what you are looking for? &lt;/span&gt;Search this site, for frequently asked ASP.NET, C#, SQL Server, WCF and HR Interview Questions&lt;form action="http://venkatsqlinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input type="hidden" name="cx" value="partner-pub-5905727831268054:udrn7rdunu6" /&gt;&lt;input type="hidden" name="cof" value="FORID:11" /&gt;&lt;input type="hidden" name="ie" value="ISO-8859-1" /&gt;&lt;input type="text" name="q" size="40" /&gt;&lt;input type="submit" name="sa" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-8572772108727889617?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jvWerdaaq7VER71ZpiEwUNNV2Qk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jvWerdaaq7VER71ZpiEwUNNV2Qk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jvWerdaaq7VER71ZpiEwUNNV2Qk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jvWerdaaq7VER71ZpiEwUNNV2Qk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/fEQ4J7A_ZvM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/8572772108727889617/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/06/search-results.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8572772108727889617?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8572772108727889617?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/fEQ4J7A_ZvM/search-results.html" title="Search Results" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/06/search-results.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQGRXk_eSp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-3600433387911127990</id><published>2011-05-22T06:14:00.000-07:00</published><updated>2012-01-22T09:28:44.741-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:28:44.741-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server Interview Questions by topic" /><title>SQL Server Interview Questions by topic</title><content type="html">&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="color: #0066cc; font-family: Arial; font-size: small; width: 60%;"&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;&lt;strong&gt;On this page you can see list of all SQL Server Interview Questions by topic. In most of the interviews, these questions are very frequently asked. If you have an asp.net question that is asked in a previous interview, please post it here.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
google_ad_host = "pub-1556223355139109";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Basic SQL Server Interview Questions&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/07/what-is-difference-between-having-and.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;What is the difference between Having and Where clause&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_2213.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;SQL Server Interview Questions on Temporary Tables&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
google_ad_host = "pub-1556223355139109";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;SQL Server Interview Questions on Indexes - Part 1&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_07.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;SQL Server Interview Questions on Indexes - Part 2&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-temporary.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;What is the difference between a Temporary Table and a Table Variable&lt;/span&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-use-of-coalesce-in-sql-server.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;What is the use of COALESCE in SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_10.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;SQL Server Interview Questions on triggers&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-user-defined.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Difference between User Defined Function and Stored Procedure&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;SQL Server Interview Questions on Views - Part 1&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views_16.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;SQL Server Interview Questions on Views - Part 2&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Basic SQL Server Interview Questions on Joins&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Explain Inner Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Explain Left Outer Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/right-outer-join-with-example.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Explain Right Outer Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/full-outer-join-in-sql-server-with.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Explain Full Outer Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/self-join-with-example.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Explain Self Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/difference-between-index-scan-and-index.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;What is the difference between Index Scan and Index Seek&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/07/delete-from-tables-involved-in-sql-join.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;Write a SQL Query to delete from a table that is involved in a SQL join&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/07/advantages-of-stored-procedures.html"&gt;&lt;span style="color: #0066cc; text-decoration: none;"&gt;What are the advantages of using stored procedures?&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-3600433387911127990?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/O-gTNxcD57zajxkbwCkZkds1pks/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/O-gTNxcD57zajxkbwCkZkds1pks/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/O-gTNxcD57zajxkbwCkZkds1pks/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/O-gTNxcD57zajxkbwCkZkds1pks/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/yOu7yX_Fqb0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/3600433387911127990/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/3600433387911127990?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/3600433387911127990?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/yOu7yX_Fqb0/sql-server-interview-questions-by-topic.html" title="SQL Server Interview Questions by topic" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMESH4-fyp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-727904083381715374</id><published>2011-05-21T03:24:00.000-07:00</published><updated>2012-01-22T09:30:09.057-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:30:09.057-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="table scan" /><category scheme="http://www.blogger.com/atom/ns#" term="Difference between Index Scan and Index Seek" /><title>Difference between Index Scan and Index Seek</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Index Scan:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Index Scan &lt;/strong&gt;scans each and every record in the index. &lt;strong&gt;Table Scan &lt;/strong&gt;is where the table is processed row by row from beginning to end. If the index is a clustered index then an &lt;strong&gt;index scan&lt;/strong&gt; is really a &lt;strong&gt;table scan&lt;/strong&gt;. Since a scan touches every row in the table whether or not it qualifies, the cost is proportional to the total number of rows in the table. &lt;strong&gt;&lt;span style="color: red;"&gt;Hence, a scan is an efficient strategy only if the table is small.&lt;/span&gt;&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Index Seek:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Since a seek only touches rows that qualify and pages that contain these qualifying rows, the cost is proportional to the number of qualifying rows and pages rather than to the total number of rows in the table. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;I have an &lt;strong&gt;employee &lt;/strong&gt;table as shown in the diagram below. EmployeeId is the primary key. We have a clustered index on the employeeId column. &lt;/span&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;img border="0" j8="true" src="http://3.bp.blogspot.com/-Zy43d-GW4W4/TdeSgwliL4I/AAAAAAAAAGA/jV85y8QIJYI/s1600/IndexScan.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Query 1&lt;/strong&gt; : &lt;strong&gt;&lt;span style="color: blue;"&gt;Select &lt;/span&gt;* from Employee &lt;span style="color: blue;"&gt;where&lt;/span&gt; FirstName=&lt;span style="color: red;"&gt;'Ben'&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Query 2&lt;/strong&gt; : &lt;strong&gt;&lt;span style="color: blue;"&gt;Select&lt;/span&gt; * from Employee &lt;span style="color: blue;"&gt;where&lt;/span&gt; EmployeeId=2&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Query 1 will do an &lt;strong&gt;Index scan &lt;/strong&gt;(Table Scan) to retrieve the record as there is no Index on the FirstName column. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Query 2 will do an &lt;strong&gt;Index seek &lt;/strong&gt;to retrieve the record as there is an Index on the EmployeeId column. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;So from this example, you should have understood that, a query will result into an index seek, only if there is an index on the table to help they query to retrieve the data.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-727904083381715374?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/he4Cu_IjBnwmTK9jztT7ntp6U1c/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/he4Cu_IjBnwmTK9jztT7ntp6U1c/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/he4Cu_IjBnwmTK9jztT7ntp6U1c/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/he4Cu_IjBnwmTK9jztT7ntp6U1c/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/eqvW_0eVP28" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/727904083381715374/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/difference-between-index-scan-and-index.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/727904083381715374?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/727904083381715374?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/eqvW_0eVP28/difference-between-index-scan-and-index.html" title="Difference between Index Scan and Index Seek" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Zy43d-GW4W4/TdeSgwliL4I/AAAAAAAAAGA/jV85y8QIJYI/s72-c/IndexScan.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/difference-between-index-scan-and-index.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIHQHgyeyp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-6256674682062690527</id><published>2011-05-21T02:03:00.000-07:00</published><updated>2012-01-22T09:32:11.693-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:32:11.693-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Self Join with an example" /><category scheme="http://www.blogger.com/atom/ns#" term="selfjoin in sql server" /><category scheme="http://www.blogger.com/atom/ns#" term="self join in sql server" /><category scheme="http://www.blogger.com/atom/ns#" term="Self Join" /><category scheme="http://www.blogger.com/atom/ns#" term="selfjoin" /><title>Self Join with an example</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;There are 3 different types of joins available in sql server, and they are&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Cross Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Inner Join or Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; Outer Join&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Outer Join &lt;/strong&gt;is again divided into 3 types as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Left Outer Join or Left Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Right Outer Join or Right Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; Full Outer Join or Full Join &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;I strongly recomend to learn about the basics and types of joins, before reading this article. Read the articles below, before proceeding with self join.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;&lt;strong&gt;1.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt;Basics of Joins&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;&lt;strong&gt;2.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html"&gt;Inner Join&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;&lt;strong&gt;3.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html"&gt;Left Outer Join&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;&lt;strong&gt;4.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/right-outer-join-with-example.html"&gt;Right Outer Join&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial;"&gt;&lt;strong&gt;5.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/full-outer-join-in-sql-server-with.html"&gt;Full Outer Join&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Self join &lt;/strong&gt;is not a different type of join. &lt;strong&gt;Self join &lt;/strong&gt;means joining a table with itself. We can have an &lt;strong&gt;inner self join &lt;/strong&gt;or &lt;strong&gt;outer self join&lt;/strong&gt;. Let us try to understand with an &lt;strong&gt;example&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;To set up the data for the &lt;strong&gt;example&lt;/strong&gt;, use the script below to create &lt;strong&gt;Employee Table &lt;/strong&gt;and populate it with some sample data. We will be using &lt;strong&gt;Employee Table &lt;/strong&gt;to understand &lt;strong&gt;Self Join&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; EMPLOYEE&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;[EMPLOYEEID] &lt;span style="color: blue;"&gt;INT PRIMARY KEY&lt;/span&gt;,&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;[NAME] &lt;span style="color: blue;"&gt;NVARCHAR(50)&lt;/span&gt;,&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;[MANAGERID] &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; EMPLOYEE &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;(101,&lt;span style="color: red;"&gt;'Mary'&lt;/span&gt;,102)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; EMPLOYEE &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;(102,&lt;span style="color: red;"&gt;'Ravi'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; EMPLOYEE &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;(103,&lt;span style="color: red;"&gt;'Raj'&lt;/span&gt;,102)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; EMPLOYEE &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;(104,&lt;span style="color: red;"&gt;'Pete'&lt;/span&gt;,103)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; EMPLOYEE &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;(105,&lt;span style="color: red;"&gt;'Prasad'&lt;/span&gt;,103)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT INTO&lt;/span&gt; EMPLOYEE &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;(106,&lt;span style="color: red;"&gt;'Ben'&lt;/span&gt;,103)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;We use &lt;strong&gt;Self Join&lt;/strong&gt;, if we have a &lt;strong&gt;table &lt;/strong&gt;that references itself. For &lt;strong&gt;example&lt;/strong&gt;, In the &lt;strong&gt;Employee Table &lt;/strong&gt;below MANAGERID column references EMPLOYEEID column. So the table is said to &lt;strong&gt;referencing itself&lt;/strong&gt;. This is the right scenario where we can use &lt;strong&gt;Self Join&lt;/strong&gt;. 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.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://2.bp.blogspot.com/-hE83aq6KeKY/Tdd-iy4fj5I/AAAAAAAAAFw/u9x2hjMciYw/s1600/EmployeeTable.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
The query below is an example of &lt;strong&gt;Self Join&lt;/strong&gt;. Both E1 and E2 refer to the same &lt;strong&gt;Employee &lt;/strong&gt;Table. In this query we are joining the &lt;strong&gt;Employee&lt;/strong&gt; Table with itself. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; E1.[NAME],E2.[NAME] &lt;span style="color: blue;"&gt;AS&lt;/span&gt; [MANAGER NAME]&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; EMPLOYEE E1 &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INNER JOIN&lt;/span&gt; EMPLOYEE E2 &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; E2.EMPLOYEEID =E1.MANAGERID&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If we run the above query we only get 5 rows out of the 6 rows as shown below.&lt;/span&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Inner Self Join&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/-um9BNVkV9Xs/TdeAOvs5wxI/AAAAAAAAAF0/QpJ1MrGiPOY/s1600/InnerSelfJoin.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
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 &lt;strong&gt;LEFT OUTER JOIN &lt;/strong&gt;as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; E1.[NAME],E2.[NAME] AS [MANAGER NAME]&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; EMPLOYEE E1 &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;LEFT OUTER JOIN&lt;/span&gt; EMPLOYEE E2 &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; E2.EMPLOYEEID =E1.MANAGERID&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;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.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Left Outer Self Join&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/--JIy9u-2qDk/TdeCX2vxuPI/AAAAAAAAAF4/I10IaVn8KsY/s1600/LeftOuterSelfJoin.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
Let us now slightly modify the above query using &lt;strong&gt;COALESCE &lt;/strong&gt;as shown below. Read &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-use-of-coalesce-in-sql-server.html"&gt;COALESCE function in SQL Server&lt;/a&gt; to understand &lt;strong&gt;COALESCE &lt;/strong&gt;in a greater detail.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; E1.[NAME],&lt;span style="color: magenta;"&gt;COALESCE&lt;/span&gt;(E2.[NAME],&lt;span style="color: red;"&gt;'No Manager'&lt;/span&gt;)&amp;nbsp;&lt;span style="color: blue;"&gt;AS&lt;/span&gt; [MANAGER NAME]&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM &lt;/span&gt;EMPLOYEE E1 &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;LEFT JOIN&lt;/span&gt; EMPLOYEE E2 &lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; E2.EMPLOYEEID =E1.MANAGERID&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If we execute the above query the output will be as shown in the image below. This is how &lt;strong&gt;COALESCE&lt;/strong&gt; can be used.&lt;/span&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;span style="color: #660000; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Left Outer Self Join with COALESCE&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/-8SrwcgzOQZE/TdeES3ohXgI/AAAAAAAAAF8/5TTCKtTiNcU/s1600/SlefJoinCoalesce.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-6256674682062690527?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/noOpA4GHhELYpdpFuPV22eM8fy0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/noOpA4GHhELYpdpFuPV22eM8fy0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/noOpA4GHhELYpdpFuPV22eM8fy0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/noOpA4GHhELYpdpFuPV22eM8fy0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/N-UUg_dG0R4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/6256674682062690527/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/self-join-with-example.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/6256674682062690527?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/6256674682062690527?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/N-UUg_dG0R4/self-join-with-example.html" title="Self Join with an example" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-hE83aq6KeKY/Tdd-iy4fj5I/AAAAAAAAAFw/u9x2hjMciYw/s72-c/EmployeeTable.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/self-join-with-example.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUINQHw_eyp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-7040211452440592705</id><published>2011-05-20T13:38:00.000-07:00</published><updated>2012-01-22T09:33:11.243-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:33:11.243-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Full Outer Join" /><category scheme="http://www.blogger.com/atom/ns#" term="Full Outer Join in SQL Server with an example" /><category scheme="http://www.blogger.com/atom/ns#" term="Full Outer Join in SQL Server" /><title>Full Outer Join in SQL Server with an example</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Inner Join and left join &lt;/strong&gt;are the most commonly used joins in real time projects. It is very important that you understand the basics of joins before reading this article.&amp;nbsp;Please read the articles below if you have not done so already.&lt;br /&gt;
&lt;strong&gt;1.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt;Basics of Joins in SQL Server&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html"&gt;Inner Join&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html"&gt;Left Join&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;4.&lt;/strong&gt; &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/right-outer-join-with-example.html"&gt;Right Join&lt;/a&gt;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
Now, let us understand&amp;nbsp;&lt;strong&gt;Full Outer&amp;nbsp;join with an example.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Create 2 tables &lt;strong&gt;Company &lt;/strong&gt;and &lt;strong&gt;Candidate&lt;/strong&gt;. Use the script below to create these tables and populate them. CompanyId column in Candidate Table is a foreign key referencing CompanyId in Company Table.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Company&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;TinyInt Identity Primary Key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyName &lt;span style="color: blue;"&gt;Nvarchar(50) NULL&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'DELL'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'HP'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'IBM'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'Microsoft'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Candidate&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CandidateId &lt;span style="color: blue;"&gt;tinyint identity primary key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FullName &lt;span style="color: blue;"&gt;nvarchar(50) NULL,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;tinyint REFERENCES Company(CompanyId)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ron'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Pete'&lt;/span&gt;,2)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ravi'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Raj'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Kiran'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you want to select all the rows from the &lt;strong&gt;LEFT Table &lt;/strong&gt;( In our example &lt;strong&gt;Candidate &lt;/strong&gt;Table ) plus all the rows from the &lt;strong&gt;RIGHT table &lt;/strong&gt;( In our example &lt;strong&gt;Company &lt;/strong&gt;Table ) , then we use &lt;strong&gt;FULL OUTER JOIN&lt;/strong&gt;. A query involving a &lt;strong&gt;FULL OUTER JOIN &lt;/strong&gt;for the &lt;strong&gt;Candidate and Company &lt;/strong&gt;Table is shown below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FULL OUTER&amp;nbsp;JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If we run the above query the output will be as shown in below. If you look at the out put, we now got 8 rows. All the rows from the &lt;strong&gt;Candidate &lt;/strong&gt;Table and all the rows from the &lt;strong&gt;Company &lt;/strong&gt;Table.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/-fva2g-6QXEM/TdbQkUDwk7I/AAAAAAAAAFs/agWHEAVk8tU/s1600/FullOuterJoin.png" /&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;Full Outer Join Result&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Instead of using &lt;strong&gt;FULL OUTER JOIN &lt;/strong&gt;keyword we can just use &lt;strong&gt;FULL JOIN &lt;/strong&gt;keyword as shown below. &lt;strong&gt;FULL OUTER JOIN or FULL JOIN &lt;/strong&gt;means the same.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FULL JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;If you can think of any other sql server interview questions please post them as comments, so they will be useful to other users like you. This will be a great help from your side to improve this site.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-7040211452440592705?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DVbAVCenqGshyRnLfOf1QS8KOKU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DVbAVCenqGshyRnLfOf1QS8KOKU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DVbAVCenqGshyRnLfOf1QS8KOKU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DVbAVCenqGshyRnLfOf1QS8KOKU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/JVi4w_IJwEo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/7040211452440592705/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/full-outer-join-in-sql-server-with.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7040211452440592705?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7040211452440592705?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/JVi4w_IJwEo/full-outer-join-in-sql-server-with.html" title="Full Outer Join in SQL Server with an example" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-fva2g-6QXEM/TdbQkUDwk7I/AAAAAAAAAFs/agWHEAVk8tU/s72-c/FullOuterJoin.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/full-outer-join-in-sql-server-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEGSHw5fCp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-4601556430821981606</id><published>2011-05-20T13:14:00.000-07:00</published><updated>2012-01-22T09:33:49.224-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:33:49.224-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Right Join in sql server" /><category scheme="http://www.blogger.com/atom/ns#" term="Right Outer Join with an example" /><title>Right Outer Join with an example</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt;Please read, Basic SQL Server Interview Questions on Joins article before reading this article.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Inner Join and left join &lt;/strong&gt;are the most commonly used joins in real time projects. &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html"&gt;Click here to read about Inner Join in SQL Server&lt;/a&gt;. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html"&gt;Click here to read about&amp;nbsp;Left Outer Join in SQL Server.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
Now, let us understand&amp;nbsp;&lt;strong&gt;Right Outer&amp;nbsp;join with an example.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Create 2 tables &lt;strong&gt;Company &lt;/strong&gt;and &lt;strong&gt;Candidate&lt;/strong&gt;. Use the script below to create these tables and populate them. CompanyId column in Candidate Table is a foreign key referencing CompanyId in Company Table.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Company&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;TinyInt Identity Primary Key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyName &lt;span style="color: blue;"&gt;Nvarchar(50) NULL&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'DELL'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'HP'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'IBM'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'Microsoft'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Candidate&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CandidateId &lt;span style="color: blue;"&gt;tinyint identity primary key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FullName &lt;span style="color: blue;"&gt;nvarchar(50) NULL,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;tinyint REFERENCES Company(CompanyId)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ron'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Pete'&lt;/span&gt;,2)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ravi'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Raj'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Kiran'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you want to select all the rows from the &lt;strong&gt;LEFT Table &lt;/strong&gt;( In our example &lt;strong&gt;Candidate &lt;/strong&gt;Table) that have non null foreign key values plus all the rows from the &lt;strong&gt;RIGHT table &lt;/strong&gt;( In our example &lt;strong&gt;Company &lt;/strong&gt;Table) including the rows that are not referenced in the &lt;strong&gt;LEFT Table&lt;/strong&gt;, then we use &lt;strong&gt;RIGHT OUTER JOIN&lt;/strong&gt;. A query involving a &lt;strong&gt;RIGHT OUTER JOIN &lt;/strong&gt;for the &lt;strong&gt;Candidate &lt;/strong&gt;and &lt;strong&gt;Company Table &lt;/strong&gt;is shown below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;RIGHT&amp;nbsp;OUTER&amp;nbsp;JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If we run the above query the output will be as shown in below. If you look at the out put, we now got 6 rows. All the rows from the &lt;strong&gt;Candidate &lt;/strong&gt;Table that has non null foreign key value plus all the rows from the &lt;strong&gt;Company &lt;/strong&gt;Table including the row that is not referenced in the &lt;strong&gt;Candidate &lt;/strong&gt;Table.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/-pBKO-hJS6Is/TdbK0UbN7NI/AAAAAAAAAFo/brTyad-PLMw/s1600/RightJoin.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Right Outer Join Results&lt;/strong&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Instead of using&amp;nbsp;&lt;strong&gt;RIGHT OUTER JOIN &lt;/strong&gt;keyword we can just use&amp;nbsp;&lt;strong&gt;RIGHT JOIN &lt;/strong&gt;keyword as shown below. &lt;strong&gt;RIGHT OUTER JOIN or&amp;nbsp;RIGHT JOIN&lt;/strong&gt; means the same.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;RIGHT&amp;nbsp;JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;If you can think of any other sql server interview questions please post them as comments, so they will be useful to other users like you. This will be a great help from your side to improve this site.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-4601556430821981606?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jGArr0oW7xwDTkDwtYMhiTrKA04/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jGArr0oW7xwDTkDwtYMhiTrKA04/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jGArr0oW7xwDTkDwtYMhiTrKA04/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jGArr0oW7xwDTkDwtYMhiTrKA04/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/CbZnzbyD9H8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/4601556430821981606/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/right-outer-join-with-example.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4601556430821981606?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4601556430821981606?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/CbZnzbyD9H8/right-outer-join-with-example.html" title="Right Outer Join with an example" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-pBKO-hJS6Is/TdbK0UbN7NI/AAAAAAAAAFo/brTyad-PLMw/s72-c/RightJoin.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/right-outer-join-with-example.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEDR388eip7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-1466964293068441386</id><published>2011-05-20T12:33:00.000-07:00</published><updated>2012-01-22T09:34:36.172-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:34:36.172-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Left Join with an example" /><category scheme="http://www.blogger.com/atom/ns#" term="Left Join in SQL Server" /><title>Left Join with an example</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt;Please read, Basic SQL Server Interview Questions on Joins article before reading this article.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Inner Join and left join &lt;/strong&gt;are the most commonly used joins in real time projects. &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html"&gt;Click here to read about Inner Join in SQL Server&lt;/a&gt;. Now, let us understand &lt;strong&gt;Left join with an example.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Create 2 tables &lt;strong&gt;Company &lt;/strong&gt;and &lt;strong&gt;Candidate&lt;/strong&gt;. Use the script below to create these tables and populate them. CompanyId column in Candidate Table is a foreign key referencing CompanyId in Company Table.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Company&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;TinyInt Identity Primary Key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyName &lt;span style="color: blue;"&gt;Nvarchar(50) NULL&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'DELL'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'HP'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'IBM'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'Microsoft'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Candidate&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CandidateId &lt;span style="color: blue;"&gt;tinyint identity primary key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FullName &lt;span style="color: blue;"&gt;nvarchar(50) NULL,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;tinyint REFERENCES Company(CompanyId)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ron'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Pete'&lt;/span&gt;,2)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ravi'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Raj'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Kiran'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you want to select all the rows from the &lt;strong&gt;LEFT table &lt;/strong&gt;( In our example &lt;strong&gt;Candidate&lt;/strong&gt; Table ) including the rows that have a null foreign key value ( CompanyId in &lt;strong&gt;Candidate &lt;/strong&gt;Table is the foreign key ) then we use &lt;strong&gt;LEFT OUTER JOIN&lt;/strong&gt;. A query involving a &lt;strong&gt;LEFT OUTER JOIN &lt;/strong&gt;for the &lt;strong&gt;Candidate and Company &lt;/strong&gt;Table is shown below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;LEFT OUTER&amp;nbsp;JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If we run the above query the output will be as shown in below. If you look at the out put, we now got all 7 rows ( All the rows from the &lt;strong&gt;Candidate&lt;/strong&gt; Table ) including the row that has a null value for the &lt;strong&gt;CompanyId&lt;/strong&gt; column in the &lt;strong&gt;Candidate &lt;/strong&gt;Table. So, &lt;strong&gt;LEFT OUTER JOIN &lt;/strong&gt;would get all the rows from the &lt;strong&gt;LEFT Table &lt;/strong&gt;including the rows that has null foreign key value.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-VeMdJ7nvrZ4/TdbA57vfNkI/AAAAAAAAAFk/wQC8W0iTaSg/s1600/LeftJoin.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" j8="true" src="http://2.bp.blogspot.com/-VeMdJ7nvrZ4/TdbA57vfNkI/AAAAAAAAAFk/wQC8W0iTaSg/s1600/LeftJoin.png" /&gt;&lt;/a&gt;&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;Left Join Result&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Instead of using &lt;strong&gt;LEFT OUTER JOIN &lt;/strong&gt;keyword we can just use &lt;strong&gt;LEFT JOIN &lt;/strong&gt;keyword as shown below. &lt;strong&gt;LEFT OUTER JOIN or LEFT JOIN&lt;/strong&gt; means the same.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;LEFT JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;If you can think of any other sql server interview questions please post them as comments, so they will be useful to other users like you. This will be a great help from your side to improve this site.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-1466964293068441386?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/9LMOv7pW6CTlC5RsMf282kGKUxo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9LMOv7pW6CTlC5RsMf282kGKUxo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/9LMOv7pW6CTlC5RsMf282kGKUxo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9LMOv7pW6CTlC5RsMf282kGKUxo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/S8OYNqKlQVg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/1466964293068441386/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/1466964293068441386?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/1466964293068441386?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/S8OYNqKlQVg/left-join-with-example.html" title="Left Join with an example" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-VeMdJ7nvrZ4/TdbA57vfNkI/AAAAAAAAAFk/wQC8W0iTaSg/s72-c/LeftJoin.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAERHwzfip7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-5366540729209043138</id><published>2011-05-18T13:08:00.000-07:00</published><updated>2012-01-22T09:35:05.286-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:35:05.286-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="Inner Join with example" /><title>Inner Join with an example</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt;Please read, Basic SQL Server Interview Questions on Joins article before reading this article.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Inner Join and left join &lt;/strong&gt;are the most commonly used joins in real time projects. We will talk about left join in a later article. Now, let us understand &lt;strong&gt;Inner join with an example.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Create 2 tables &lt;strong&gt;Company &lt;/strong&gt;and &lt;strong&gt;Candidate&lt;/strong&gt;. Use the script below to create these tables and populate them. CompanyId column in Candidate Table is a foreign key referencing CompanyId in Company Table.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Company&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;TinyInt Identity Primary Key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyName &lt;span style="color: blue;"&gt;Nvarchar(50) NULL&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'DELL'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'HP'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'IBM'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'Microsoft'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Candidate&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CandidateId &lt;span style="color: blue;"&gt;tinyint identity primary key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FullName &lt;span style="color: blue;"&gt;nvarchar(50) NULL,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;tinyint REFERENCES Company(CompanyId)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ron'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Pete'&lt;/span&gt;,2)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ravi'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Raj'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Kiran'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you want to select all the rows from the &lt;strong&gt;LEFT table&lt;/strong&gt;(In our example &lt;strong&gt;Candidate Table&lt;/strong&gt;) that have a non null foreign key value(CompanyId in &lt;strong&gt;Candidate Table &lt;/strong&gt;is the foreign key) then we use &lt;strong&gt;INNER JOIN&lt;/strong&gt;. A query involving an &lt;strong&gt;INNER JOIN &lt;/strong&gt;for the &lt;strong&gt;Candidate and Company &lt;/strong&gt;Table is shown below. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INNER JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If we run the above query the output will be as shown in the image below. If you look at the out put, we only got 5 rows. We did not get the 2 rows which has NULL value in the CompanyId column. So an INNER JOIN would get all the rows from the LEFT Table that has non null foreign key value.&lt;/span&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://3.bp.blogspot.com/-QVR5dY6zHWI/TdQlpUaVEGI/AAAAAAAAAFg/WT0wMHOByWM/s1600/InnerJoin.png" /&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;Inner Join Result&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Instead of using &lt;strong&gt;INNER JOIN &lt;/strong&gt;keyword we can just use &lt;strong&gt;JOIN &lt;/strong&gt;keyword as shown below. &lt;strong&gt;JOIN &lt;/strong&gt;or &lt;strong&gt;INNER JOIN &lt;/strong&gt;means the same.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Cand.CandidateId, Cand.FullName, Cand.CompanyId, Comp.CompanyId, Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;JOIN&lt;/span&gt; Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; Cand.CompanyId = Comp.CompanyId&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;If you can think of any other sql server interview questions please post them as comments, so they will be useful to other users like you. This will be a great help from your side to improve this site.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-5366540729209043138?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/i4g9rBZxEae1OtFRi2qapfYyfQ0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/i4g9rBZxEae1OtFRi2qapfYyfQ0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/i4g9rBZxEae1OtFRi2qapfYyfQ0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/i4g9rBZxEae1OtFRi2qapfYyfQ0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/GPWWytBxh7E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/5366540729209043138/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/5366540729209043138?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/5366540729209043138?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/GPWWytBxh7E/inner-join-with-example.html" title="Inner Join with an example" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-QVR5dY6zHWI/TdQlpUaVEGI/AAAAAAAAAFg/WT0wMHOByWM/s72-c/InnerJoin.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAHSXY7eip7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-6951450707830012125</id><published>2011-05-17T12:20:00.000-07:00</published><updated>2012-01-22T09:35:38.802-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:35:38.802-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="example" /><category scheme="http://www.blogger.com/atom/ns#" term="cross join" /><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="joins" /><title>Basic SQL Server Interview Questions on Joins</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What are the different types of joins available in sql server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;There are 3 different types of joins available in sql server, and they are&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Cross Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Inner Join or Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; Outer Join&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Outer Join is again divided into 3 types as shown below.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Left Outer Join or Left Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Right Outer Join or Right Join &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; Full Outer Join or Full Join &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;You might have heard about self join, but self join is not a different type of join. A self join means joining a table with itself. We can have an inner self join or outer self join. Read this sql server interview question, to understand self join in a greater detail.&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is cross join. Explain with an example?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Let us understand Cross Join with an example. Create 2 tables &lt;strong&gt;&lt;span style="color: #20124d;"&gt;Company&lt;/span&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;span style="color: #20124d;"&gt;Candidate&lt;/span&gt;&lt;/strong&gt;. Use the script below to create these tables and populate them. CompanyId column in Candidate Table is a foreign key referencing CompanyId in Company Table.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Company&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;TinyInt Identity Primary Key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyName &lt;span style="color: blue;"&gt;Nvarchar(50) NULL&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'DELL'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'HP'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'IBM'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Company VALUES(&lt;span style="color: red;"&gt;'Microsoft'&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CREATE TABLE&lt;/span&gt; Candidate&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;(&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CandidateId &lt;span style="color: blue;"&gt;tinyint identity primary key,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FullName &lt;span style="color: blue;"&gt;nvarchar(50) NULL,&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CompanyId &lt;span style="color: blue;"&gt;tinyint REFERENCES Company(CompanyId)&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ron'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Pete'&lt;/span&gt;,2)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Steve'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Ravi'&lt;/span&gt;,1)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Raj'&lt;/span&gt;,3)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; Candidate VALUES(&lt;span style="color: red;"&gt;'Kiran'&lt;/span&gt;,NULL)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;GO&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;A cross join produces the Cartesian product of the tables involved in the join. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table. A query involving a CROSS JOIN for the &lt;strong&gt;&lt;span style="color: #20124d;"&gt;Candidate&lt;/span&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;span style="color: #20124d;"&gt;Company&lt;/span&gt;&lt;/strong&gt; Table is shown below.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt;&amp;nbsp; Cand.CandidateId,Cand.FullName,Cand.CompanyId, &lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Comp.CompanyId,Comp.CompanyName&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;FROM &lt;/span&gt;Candidate Cand&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;CROSS JOIN &lt;/span&gt;Company Comp&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;If we run the above query, we produce the result set shown in the image below.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/-1v1yCC3atic/TdLLTiUBP8I/AAAAAAAAAFc/yyy3OdmD5Jk/s1600/CrossJoin.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Key Points to remember about CROSS JOIN.&lt;/strong&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; A cross join produces the Cartesian product of the tables involved in the join.This mean every row in the Left Table is joined to every row in the Right Table. &lt;strong&gt;&lt;span style="color: #20124d;"&gt;Candidate&lt;/span&gt;&lt;/strong&gt; is LEFT Table and &lt;strong&gt;&lt;span style="color: #20124d;"&gt;Company&lt;/span&gt;&lt;/strong&gt; is RIGHT Table. In our example we have 28 total number of rows in the result set. 7 rows in the Candidate table multiplied by 4 rows in the Company Table. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; In real time scenarios we rarley use CROSS JOIN. Most often we use either INNER JOIN or LEFT OUTER JOIN. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; CROSS JOIN does not have an ON clause with a Join Condition. All the other JOINS use ON clause with a Join Condition. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;4.&lt;/strong&gt; Using an ON clause on a CROSS JOIN would generate a syntax error. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; Understanding the above key points will help you answer any follow up interview questions on cross join in sql server.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;If you can think of any other sql server interview questions please post them as comments, so they will be useful to other users like you. This will be a great help from your side to improve this site.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-6951450707830012125?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3NrQ7dlWn28PjGroknOOxnhWrgY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3NrQ7dlWn28PjGroknOOxnhWrgY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3NrQ7dlWn28PjGroknOOxnhWrgY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3NrQ7dlWn28PjGroknOOxnhWrgY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/z5s0HCgFi1Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/6951450707830012125/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/6951450707830012125?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/6951450707830012125?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/z5s0HCgFi1Y/basic-sql-server-interview-questions-on.html" title="Basic SQL Server Interview Questions on Joins" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-1v1yCC3atic/TdLLTiUBP8I/AAAAAAAAAFc/yyy3OdmD5Jk/s72-c/CrossJoin.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8FQ3k5fSp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-4451551949313547315</id><published>2011-05-16T12:45:00.000-07:00</published><updated>2012-01-22T09:36:52.725-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:36:52.725-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="advantages of using views" /><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="materialized views" /><category scheme="http://www.blogger.com/atom/ns#" term="indexed views" /><title>SQL Server Interview Questions on Views - Part 2</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Can you create a view based on other views?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Yes&lt;/strong&gt;, you can create a view &lt;strong&gt;based on other views&lt;/strong&gt;. Usually we create views based on tables, but it also possible to create views based on views.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Can you update views?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Yes&lt;/strong&gt;, views can be updated. However, updating a view that is based on multiple tables, may not update the underlying tables &lt;strong&gt;&lt;span style="color: red;"&gt;correctly&lt;/span&gt;&lt;/strong&gt;. To correctly update a view that is based on multiple tables you can make use &lt;strong&gt;INSTEAD OF triggers &lt;/strong&gt;in SQL Server. &lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_10.html"&gt;Click here for a real time example, that we have already discussed in SQL Server Interview Questions on triggers article.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What are indexed views?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Or&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What are materialized views?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;A view is a virtual table, it does not contain any physical data. A view is nothing more than compiled SQL query. Every time, we issue a select query against a view, we actually get the data from the underlying base tables and not from the view, as the view itself does not contain any data.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;When you create an index on a view, the data gets physically stored in the view. So, when we issue a select query against an indexed view, the data is retrieved from the index without having to go to the underlying table, which will make the select statement to work slightly faster. However, the disadvantage is, INSERT, UPDATE and DELETE operations will become a little slow, because every time you insert or delete a row from the underlying table, the view index needs to be updated. Inshort, DML operations will have negative impact on performance.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Oracle refers to indexed views as materialized views.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Only the views created with schema binding, can have an Index. Simply adding WITH SCHEMABINDING to the end of the CREATE VIEW statement will accomplish this. However, the effect is that any changes to the underlying tables which will impact the view are not allowed. Since the indexed view is stored physically, any schema changes would impact the schema of the stored results set. Therefore, SQL Server requires that schema binding be used to prevent the view's schema (and therefore the underlying tables) from changing.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The first index for a view must be a UNIQUE CLUSTERED INDEX, after which, it's possible to create non-clustered indexes against the view.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Indexed Views are heavily used in data warehouses and reporting databases that are not highly transactional.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What are the limitations of a View?&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;1.&lt;/strong&gt; You cannot pass parameters to a view.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;2.&lt;/strong&gt; Rules and Defaults cannot be associated with views.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;3.&lt;/strong&gt; The ORDER BY clause is invalid in views unless TOP or FOR XML is also specified.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;4.&lt;/strong&gt; Views cannot be based on temporary tables.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: #20124d; font-family: Arial, Helvetica, sans-serif;"&gt;If you can think of any other interview questions on views please post them as comments, so they will be useful to other users like you.&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-4451551949313547315?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XcRmTVxyESKgolZGK3bFzA3iucw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XcRmTVxyESKgolZGK3bFzA3iucw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XcRmTVxyESKgolZGK3bFzA3iucw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XcRmTVxyESKgolZGK3bFzA3iucw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/dSeDZRPURsY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/4451551949313547315/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views_16.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4451551949313547315?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4451551949313547315?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/dSeDZRPURsY/sql-server-interview-questions-on-views_16.html" title="SQL Server Interview Questions on Views - Part 2" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views_16.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8ASXo5cCp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-8116954869382628727</id><published>2011-05-15T12:56:00.000-07:00</published><updated>2012-01-22T09:37:28.428-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:37:28.428-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="advantages of using views" /><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><title>SQL Server Interview Questions on Views - Part 1</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;br /&gt;
What is a View in SQL Server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;You can think of a &lt;strong&gt;view&lt;/strong&gt; either as a &lt;strong&gt;compiled sql query &lt;/strong&gt;or a &lt;strong&gt;virtual &lt;/strong&gt;table. As a view represents a virtual table, it does not physically store any data. When you query a view, you actually retrieve the data from the underlying base tables.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What are the advantages of using views?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Or &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;When do you usually use views?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Views can be used to implement row level and column level security.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Example 1:&lt;/strong&gt; Consider the &lt;strong&gt;tblEmployee&lt;/strong&gt; table below. I don't want some of the users to have access to the salary column, but they should still be able to access ID, NAME and DEPT columns. If I grant access to the table, the users will be able to see all the columns. So, to achieve this, I can &lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;create a view as shown in &lt;strong&gt;Listing 1&lt;/strong&gt; below. Now, grant access to the view and not the table. So using views we can provide &lt;strong&gt;column level security&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;tblEmployee&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/-M6kUTahKBuM/Tcwedojw4nI/AAAAAAAAAFU/bHEA1r5iRHo/s1600/ViewBaseTable.png" /&gt;&lt;/div&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;Listing 1&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Create View&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vWEmployee&lt;br /&gt;
&lt;span style="color: blue;"&gt;As&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Select&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ID, Name, Dept&lt;br /&gt;
&lt;span style="color: blue;"&gt;From&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tblEmployee&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Example 2:&lt;/strong&gt; Let us say, we have a few users who should be able to access only &lt;strong&gt;IT employee&lt;/strong&gt; details and not any other dept. To do this, I can create a view as shown in &lt;strong&gt;Listing 2&lt;/strong&gt; below. Now, grant access only to the view &lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;and not the table. So using views we can provide row level security as well.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: blue;"&gt;Listing 2&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Create View&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;vWITEmployees&lt;br /&gt;
&lt;span style="color: blue;"&gt;As&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Select&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID, Name, Dept&lt;br /&gt;
&lt;span style="color: blue;"&gt;From&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tblEmployee&lt;br /&gt;
&lt;span style="color: blue;"&gt;Where&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dept = &lt;span style="color: red;"&gt;'IT'&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Simplify the database schema to the users. You can create a view based on multiple tables which join columns from all these multiple tables so that they look like a single table.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; Views can be used to present &lt;strong&gt;aggregated &lt;/strong&gt;and &lt;strong&gt;summarized &lt;/strong&gt;data.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Example 1:&lt;/strong&gt; Consider the &lt;strong&gt;tblEmployee&lt;/strong&gt; table above. I want to aggregate the data as shown in the image below. To do this I can create a view as shown in &lt;strong&gt;Listing 3&lt;/strong&gt;. Now, you can simply issue a select query&amp;nbsp;against the&amp;nbsp;view rather than writing a complex query every time you want to retrieve the aggregated data.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="0" j8="true" src="http://4.bp.blogspot.com/-3gjWYSDkjh4/TcwieMlRYLI/AAAAAAAAAFY/aUkR3qMY-bQ/s1600/GroupedData.png" /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;span style="color: blue;"&gt;Listing 3&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;Select&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dept, &lt;span style="color: magenta;"&gt;Count&lt;/span&gt;(*) &lt;span style="color: blue;"&gt;As&lt;/span&gt; Total&lt;br /&gt;
&lt;span style="color: blue;"&gt;From&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tblEmployee&lt;br /&gt;
&lt;span style="color: blue;"&gt;Group By&lt;/span&gt;&amp;nbsp;&amp;nbsp; Dept&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;If you can think of any other advantages of using views please post them as comments, so they will be useful to other users like you. &lt;/strong&gt;&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-8116954869382628727?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/p765uawOMDui1TohTQIc9ypNaDo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p765uawOMDui1TohTQIc9ypNaDo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/p765uawOMDui1TohTQIc9ypNaDo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p765uawOMDui1TohTQIc9ypNaDo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/QAzsferwQx4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/8116954869382628727/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8116954869382628727?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8116954869382628727?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/QAzsferwQx4/sql-server-interview-questions-on-views.html" title="SQL Server Interview Questions on Views - Part 1" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-M6kUTahKBuM/Tcwedojw4nI/AAAAAAAAAFU/bHEA1r5iRHo/s72-c/ViewBaseTable.png" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8MQ3k4fSp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-8063214504972682315</id><published>2011-05-13T09:53:00.000-07:00</published><updated>2012-01-22T09:38:02.735-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:38:02.735-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="difference between a User Defined Function and a Stored Procedure in SQL Server" /><category scheme="http://www.blogger.com/atom/ns#" term="difference between a UDF and an SP in SQL Server" /><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><title>What is the difference between a User Defined Function (UDF) and a Stored Procedure (SP) in SQL Server</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt; &lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;br /&gt;
1. Stored Procedure &lt;/strong&gt;support deffered name resolution where as &lt;strong&gt;functions &lt;/strong&gt;do not support deffered name resolution. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2. User Defined Function &lt;/strong&gt;can be used in a select statement where as you cannot use a &lt;strong&gt;stored procedure &lt;/strong&gt;in a select statement. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3. UDF&lt;/strong&gt;'s cannot return Image, Text where as a &lt;strong&gt;StoredProcedure&lt;/strong&gt; can return any datatype. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;4.&lt;/strong&gt; In general &lt;strong&gt;User Defined Functions &lt;/strong&gt;are used for computations where as &lt;strong&gt;Stored Procedures &lt;/strong&gt;are used for performing business logic. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;5. UDF &lt;/strong&gt;should return a value where as &lt;strong&gt;Stored Procedure &lt;/strong&gt;need not. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;6. User Defined Functions &lt;/strong&gt;accept lesser number of input parameters than &lt;strong&gt;Stored Procedures. UDF &lt;/strong&gt;can have upto 1023 input parameters where as a &lt;strong&gt;Stored Procedure &lt;/strong&gt;can have upto 21000 input parameters. &lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;7.&lt;/strong&gt; Temporary Tables can not be used in a &lt;strong&gt;UDF &lt;/strong&gt;where as a &lt;strong&gt;StoredProcedure &lt;/strong&gt;can use Temporary Tables. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;8. UDF&lt;/strong&gt; can not Execute Dynamic SQL where as a &lt;strong&gt;Stored Procedure &lt;/strong&gt;can execute Dynamic SQL. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;9. User Defined Function &lt;/strong&gt;does not support error handling where as &lt;strong&gt;Stored Procedure &lt;/strong&gt;support error handling. RAISEERROR or @@ERROR are not allowed in &lt;strong&gt;UDF&lt;/strong&gt;s. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;If you are aware of any other differences, please post them as comments, so that they will be useful for others.&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-8063214504972682315?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/vEDxV7NyVonwEnW_2zfu54SqNNU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vEDxV7NyVonwEnW_2zfu54SqNNU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/vEDxV7NyVonwEnW_2zfu54SqNNU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vEDxV7NyVonwEnW_2zfu54SqNNU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/ybjlrLnTG-M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/8063214504972682315/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-user-defined.html#comment-form" title="12 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8063214504972682315?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/8063214504972682315?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/ybjlrLnTG-M/what-is-difference-between-user-defined.html" title="What is the difference between a User Defined Function (UDF) and a Stored Procedure (SP) in SQL Server" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>12</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-user-defined.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4BQn07cSp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-6666942579608414143</id><published>2011-05-10T13:56:00.000-07:00</published><updated>2012-01-22T09:39:13.309-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:39:13.309-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server Interview Questions on triggers" /><title>SQL Server Interview Questions on triggers</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is a Trigger in SQL Server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;A Trigger is a database object that is attached to a table. In many aspects it is similar to a stored procedure. As a matter of fact, triggers are often referred to as a "special kind of stored procedure." The main difference between a trigger and a stored procedure is that the former is attached to a table and is only fired when an INSERT, UPDATE or DELETE occurs.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What are the two types of Triggers in SQL Server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1. After Triggers : &lt;/strong&gt;Fired after Insert, Update and Delete operations on a table.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2. Instead of Triggers: &lt;/strong&gt;Fired instead of Insert, Update and Delete operations on a table.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What are the special tables used by Triggers in SQL Server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Triggers &lt;/strong&gt;make use of two special tables called &lt;strong&gt;inserted&lt;/strong&gt; and &lt;strong&gt;deleted&lt;/strong&gt;. The &lt;strong&gt;inserted &lt;/strong&gt;table contains the data referenced in an INSERT before it is actually committed to the database. The &lt;strong&gt;deleted &lt;/strong&gt;table contains the data in the underlying table referenced in a DELETE before it is actually removed from the database. When an UPDATE is issued both tables are used. More specifically, the new data referenced in the UPDATE statement is contained in &lt;strong&gt;inserted &lt;/strong&gt;table and the data that is being updated is contained in &lt;strong&gt;deleted &lt;/strong&gt;table.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Give a real time example for triggers usage?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;It is recomended to avoid triggers in a real time environment. There is one scenario I can think of why you may want to use triggers in a real time environment. Let us use an example to understand this.&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;I have 2 tables, &lt;strong&gt;tblPerson &lt;/strong&gt;and &lt;strong&gt;tblGender&lt;/strong&gt; as shown below. &lt;strong&gt;GenderId &lt;/strong&gt;is the foriegn key in &lt;strong&gt;tblPerson &lt;/strong&gt;table.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://2.bp.blogspot.com/-Ugc6i7kn2hI/TcmlRO6JWJI/AAAAAAAAAE8/I5hgINVEowM/s1600/Tables.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
Now create a view based on the above 2 tables as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://4.bp.blogspot.com/-vig9OaUW32U/TcmmtknmgqI/AAAAAAAAAFA/xwV7kZdFlDI/s1600/ViewOnMultipleTables.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Select * from &lt;strong&gt;vWPersons&lt;/strong&gt; will give us the result as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://4.bp.blogspot.com/-zCCwM2LHGo8/Tcmnm0FkcvI/AAAAAAAAAFE/t34g_SSxPz0/s1600/ViewResult.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Now update the view the following query. This will change the Gender Text to &lt;strong&gt;Female&lt;/strong&gt; in &lt;strong&gt;tblGender &lt;/strong&gt;table for Id = 1. This is not what we have expected.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;Update tblGender Set Gender='Female' where Id=1&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The base tables are updated incorrectly. So, Select * from &lt;strong&gt;vWPersons&lt;/strong&gt; will give us the result as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://4.bp.blogspot.com/-qa8L2rHTIAk/Tcmow25J3qI/AAAAAAAAAFI/wbGeOtr13fw/s1600/IncorrectResult.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;To update the base tables correctly, you can create an &lt;strong&gt;INSTEAD OF&lt;/strong&gt; trigger on the view as shown below.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://1.bp.blogspot.com/-yQLK8OYwKpo/TcmpbZoHRqI/AAAAAAAAAFM/Zy7GTDaCUQ0/s1600/InsteadOfTrigger.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Now run the query below which will update the underlying base tables correctly.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Update vWPersons Set Gender='Female' Where Id=1&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="color: blue;"&gt;Select * from vWPersons&lt;/span&gt;, will show the correct result set as shown below. The &lt;strong&gt;INSTEAD OF&lt;/strong&gt; trigger has correctly updated the GenderId in tblPerson table.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://3.bp.blogspot.com/-arYuQjIVnW0/TcmqaLRJeFI/AAAAAAAAAFQ/vrBpSMJUOHU/s1600/CorrectResult.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;So, &lt;strong&gt;Instead of triggers &lt;/strong&gt;can be used to facilitate &lt;strong&gt;updating Views that are based on multiple base tables&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-6666942579608414143?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2SqAbPLn1qKeRTAoO8btAIcvyic/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2SqAbPLn1qKeRTAoO8btAIcvyic/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2SqAbPLn1qKeRTAoO8btAIcvyic/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2SqAbPLn1qKeRTAoO8btAIcvyic/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/RWUrmhdaQY0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/6666942579608414143/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_10.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/6666942579608414143?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/6666942579608414143?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/RWUrmhdaQY0/sql-server-interview-questions-on_10.html" title="SQL Server Interview Questions on triggers" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-Ugc6i7kn2hI/TcmlRO6JWJI/AAAAAAAAAE8/I5hgINVEowM/s72-c/Tables.png" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_10.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcGQXc9eyp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-2793402435332835069</id><published>2011-05-09T13:31:00.000-07:00</published><updated>2012-01-22T09:40:20.963-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:40:20.963-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="What is the use of COALESCE in SQL Server" /><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><title>What is the use of COALESCE in SQL Server</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Let us understand the use of &lt;strong&gt;COALESCE&lt;/strong&gt; with the help of an example.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;In this example, the &lt;strong&gt;Candidate&lt;/strong&gt; table is shown to include three columns with information about a Candidate: &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;1. Candidate_id&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;2. PrimaryEmail&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;3. SecondaryEmail&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;COALESCE&lt;/strong&gt; in the SELECT statement below, selects the PrimaryEmail if it is not null. If the PrimaryEmail is null then SecondaryEmail will be selected. If both PrimaryEmail and SecondaryEmail is present then only PrimaryEmail is selected. So, COALESCE returns the first nonnull column among the list of columns passed. If both PrimaryEmail and SecondaryEmail is NULL, COALESCE returns NULL.&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://1.bp.blogspot.com/-6R49zlPNh6M/TchOH97_qhI/AAAAAAAAAE0/kDW8rujbq08/s1600/coalesce.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;COALESCE&lt;/strong&gt; can also be used in joins as shown in the example below. If the Candidate table has a non null value in the Email column, then the value is selected. If the Email column is null in the Candidate Table then, CompanyEmail from CandidateCompany Table is selected.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;img border="1" j8="true" src="http://1.bp.blogspot.com/-OcOSIklGodw/TchPPz2q8-I/AAAAAAAAAE4/19Dc22lIH4o/s1600/coalesce2.jpg" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-2793402435332835069?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/YT_npTdN2jPymFvIIh8sEGOpsYE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YT_npTdN2jPymFvIIh8sEGOpsYE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/YT_npTdN2jPymFvIIh8sEGOpsYE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YT_npTdN2jPymFvIIh8sEGOpsYE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/7hjccCLjcyQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/2793402435332835069/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-use-of-coalesce-in-sql-server.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/2793402435332835069?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/2793402435332835069?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/7hjccCLjcyQ/what-is-use-of-coalesce-in-sql-server.html" title="What is the use of COALESCE in SQL Server" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-6R49zlPNh6M/TchOH97_qhI/AAAAAAAAAE0/kDW8rujbq08/s72-c/coalesce.png" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/what-is-use-of-coalesce-in-sql-server.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcASHcycCp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-610985671424870098</id><published>2011-05-09T12:09:00.000-07:00</published><updated>2012-01-22T09:40:49.998-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:40:49.998-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="difference between a Temporary Table and a Table Variable" /><title>What is the difference between a Temporary Table and a Table Variable</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the difference between a Temporary Table and a Table Variable?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Or&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;When do you use Table Variable over a Temporary Table and vice versa?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Table variable is created in the memory where as a temporary table is created in the TempDB. But, if there is a memory pressure, the pages belonging to a table variable may be pushed out to tempdb.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Table variables cannot be involved in transactions, logging or locking. This makes table variable faster than a temporary table.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; You can pass table variable as parameter to functions and stored procedures, where as you cannot do the same with temporary table.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;4.&lt;/strong&gt; A temporary table can have indexes, whereas a table variable can only have a primary index. If speed is an issue Table variables can be faster, but if there are a lot of records, or there is a need to search the temporary table based on a clustered index, then a Temporary Table would be better. If you have less than 100 rows generally use a table variable. Otherwise use a temporary table. This is because SQL Server won't create statistics on table variables.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_2213.html"&gt;Read this article for more SQL Server Interview Questions on Temporary Tables.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If you know of any other differences between a Temporary Table and a Table Variable, please post them below.&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-610985671424870098?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/x05xCbalD3EyOronB8KuEtINHKU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/x05xCbalD3EyOronB8KuEtINHKU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/x05xCbalD3EyOronB8KuEtINHKU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/x05xCbalD3EyOronB8KuEtINHKU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/oZSgj6GLVYM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/610985671424870098/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-temporary.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/610985671424870098?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/610985671424870098?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/oZSgj6GLVYM/what-is-difference-between-temporary.html" title="What is the difference between a Temporary Table and a Table Variable" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-temporary.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8FSXY5eCp7ImA9WhRbEEk.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-4544136294974913720</id><published>2011-05-07T03:21:00.000-07:00</published><updated>2012-01-31T13:53:38.820-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-31T13:53:38.820-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server Interview Questions on Temporary Tables" /><title>SQL Server Interview Questions on Temporary Tables</title><content type="html">&lt;table style="border: 1px solid #000000;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="width: 180px;padding-top:1px;"&gt;&lt;span style="color: black; font-family: Arial; font-size: 8pt; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;HR Interview Questions&lt;/span&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="border-top:1px solid #000000; text-align:center;color: #0066CC; font-family: Arial; font-size: 9pt;" colspan="2"&gt;&lt;span style="color:Red"&gt;Didn't find what you are looking for? &lt;/span&gt;&lt;br /&gt;
Search this site, for frequently asked ASP.NET, C#, &lt;br /&gt;
SQL Server, WCF and HR Interview Questions&lt;form action="http://venkatsqlinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input type="hidden" name="cx" value="partner-pub-5905727831268054:udrn7rdunu6" /&gt;&lt;input type="hidden" name="cof" value="FORID:11" /&gt;&lt;input type="hidden" name="ie" value="ISO-8859-1" /&gt;&lt;input type="text" name="q" size="40" /&gt;&lt;input type="submit" name="sa" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;What are the 2 types of Temporary Tables in SQL Server?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Local Temporary Tables&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Global Temporary Tables&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;What is the difference between Local and Global Temporary Tables?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Local Temporary Tables:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Prefixed with a single pound sign (#). &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Local temporary tables are visible to that session of SQL Server which has created it. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; Local temporary tables are automatically dropped, when the session that created the temporary tables is closed.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Global Temporary Tables:&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Prefixed with two pound signs (##). &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Global temporary tables are visible to all the SQL server sessions. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; Global temporary tables are also automatically dropped, when the session that created the temporary tables is closed.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Can you create foreign key constraints on temporary tables?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;No&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Do you have to manually delete temporary tables?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;No, temporary tables are automatically dropped, when the session that created the temporary tables is closed. But if you maintain a persistent connection or if connection pooling is enabled, then it is better to explicitly drop the temporary tables you have created.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;However, It is generally considered a good coding practice to explicitly drop every temporary table you create.&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;In which database, the temporary tables get created?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;TEMPDB database.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;How can I check for the existence of a temporary table?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;img border="0" j8="true" src="http://1.bp.blogspot.com/-qcC6Qrb2e88/TcUcWrXtkPI/AAAAAAAAAEw/shlygQ7T88Y/s1600/Temporary+Table.png" /&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table style="border: 1px solid #000000;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="width: 180px;padding-top:1px;"&gt;&lt;span style="color: black; font-family: Arial; font-size: 8pt; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 8pt; line-height: 140%; padding-left: 6px; text-decoration: underline;"&gt;HR Interview Questions&lt;/span&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style="border-top:1px solid #000000; text-align:center;color: #0066CC; font-family: Arial; font-size: 9pt;" colspan="2"&gt;&lt;span style="color:Red"&gt;Didn't find what you are looking for? &lt;/span&gt;&lt;br /&gt;
Search this site, for frequently asked ASP.NET, C#, &lt;br /&gt;
SQL Server, WCF and HR Interview Questions&lt;form action="http://venkatsqlinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input type="hidden" name="cx" value="partner-pub-5905727831268054:udrn7rdunu6" /&gt;&lt;input type="hidden" name="cof" value="FORID:11" /&gt;&lt;input type="hidden" name="ie" value="ISO-8859-1" /&gt;&lt;input type="text" name="q" size="40" /&gt;&lt;input type="submit" name="sa" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-4544136294974913720?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ezq-U4DQ58mpw4U11eRPSToAFFk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ezq-U4DQ58mpw4U11eRPSToAFFk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ezq-U4DQ58mpw4U11eRPSToAFFk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ezq-U4DQ58mpw4U11eRPSToAFFk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/ZamTd58-ung" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/4544136294974913720/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_2213.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4544136294974913720?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4544136294974913720?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/ZamTd58-ung/sql-server-interview-questions-on_2213.html" title="SQL Server Interview Questions on Temporary Tables" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-qcC6Qrb2e88/TcUcWrXtkPI/AAAAAAAAAEw/shlygQ7T88Y/s72-c/Temporary+Table.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_2213.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcDSH48fip7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-7804338270199508980</id><published>2011-05-07T02:12:00.000-07:00</published><updated>2012-01-22T09:41:19.076-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:41:19.076-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server Interview Questions on Indexes" /><title>SQL Server Interview Questions on Indexes - Part 2</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;What are the disadvantages of an Index?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;There are 2 disadvantages of an Index&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1. &lt;/strong&gt;Increased Disk Space&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Insert, Update and Delete statements could be slow. In short, all DML statements could be slow.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Disk Space:&lt;/strong&gt; Indexes are stored on the disk, and the amount of space required will depend on the size of the table, and the number and types of columns used in the index. Disk space is generally cheap enough to trade for application performance, particularly when a database serves a large number of users. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Insert, Update and Delete statements could be slow:&lt;/strong&gt; Another downside to using an index is the performance implication on data modification statements. Any time a query modifies the data in a table (&lt;span style="color: blue;"&gt;INSERT, UPDATE, or DELETE&lt;/span&gt;), the database needs to update all of the indexes where data has changed. Indexing can help the database during data modification statements by allowing the database to quickly locate the records to modify, however, providing too many indexes to update can actually hurt the performance of data modifications. This leads to a delicate balancing act when tuning the database for performance.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;What are the 2 types of Indexes in SQL Server?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Clustered Index &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; Non Clustered Index&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;How many Clustered and Non Clustered Indexes can you have per table?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Clustered Index&lt;/strong&gt; - Only one Clustered Index per table. A clustered index contains all of the data for a table in the index, sorted by the index key. Phone Book is an example for Clustered Index.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Non Clustered Index &lt;/strong&gt;- You can have multiple Non Clustered Indexes per table. Index at the back of a book is an example for Non Clustered Index.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Which Index is faster, Clustered or Non Clustered Index?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Clustered Index &lt;/strong&gt;is slightly faster than Non Clustered Index. This is because, when a Non Clustered Index is used there is an extra look up from the Non Clustered Index to the table, to fetch the actual rows.&lt;/span&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;When is it usually better to create a unique nonclustered index on the primary key column?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Sometimes it is better to use a unique nonclustered index on the primary key column, and place the clustered index on a column used by more queries. For example, if the majority of searches are for the price of a product instead of the primary key of a product, the clustered index could be more effective if used on the price field.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;What is a Composite Index in SQL Server?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;or &lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;What is the advantage of using a Composite Index in SQL Server?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;or &lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;What is Covering Query?&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;A composite index &lt;/strong&gt;is an index on two or more columns. Both clustered and nonclustered indexes can be composite indexes.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;If all of the information for a query can be retrieved from an Index. A clustered index, if selected for use by the query optimizer, always covers a query, since it contains all of the data in a table.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;By creating a composite indexes, we can have covering queries.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-7804338270199508980?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MuazN9OG0L6QVfOPtRVrCtjpz1Y/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MuazN9OG0L6QVfOPtRVrCtjpz1Y/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MuazN9OG0L6QVfOPtRVrCtjpz1Y/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MuazN9OG0L6QVfOPtRVrCtjpz1Y/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/x3rKTIWf5mE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/7804338270199508980/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_07.html#comment-form" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7804338270199508980?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7804338270199508980?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/x3rKTIWf5mE/sql-server-interview-questions-on_07.html" title="SQL Server Interview Questions on Indexes - Part 2" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>10</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_07.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYBSX49eCp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-4576852895861778483</id><published>2011-05-07T02:02:00.000-07:00</published><updated>2012-01-22T09:42:38.060-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:42:38.060-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server Interview Questions on Indexes" /><title>SQL Server Interview Questions on Indexes - Part 1</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the use of an Index in SQL Server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Relational databases like SQL Server use indexes to find data quickly when a query is processed. Creating the proper index can drastically increase the performance of an application.&lt;/span&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is a table scan?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;or &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the impact of table scan on performance?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;When a SQL Server has no index to use for searching, the result is similar to the reader who looks at every page in a book to find a word. The SQL engine needs to visit every row in a table. In database terminology we call this behavior a table scan, or just scan. A full table scan of a very large table can adversely affect the performance. Creating proper indexes will allow the database to quickly narrow in on the rows to satisfy the query, and avoid scanning every row in the table. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the system stored procedure that can be used to list all the indexes that are created for a specific table?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;sp_helpindex&lt;/strong&gt; is the system stored procedure that can be used to list all the indexes that are created for a specific table. &lt;br /&gt;
&lt;br /&gt;
For example, to list all the indexes on table &lt;strong&gt;tblCustomers&lt;/strong&gt;, you can use the following command.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;EXEC sp_helpindex tblCustomers&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the purpose of query optimizer in SQL Server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;An important feature of SQL Server is a component known as the query optimizer. The query optimizer's job is to find the fastest and least resource intensive means of executing incoming queries. An important part of this job is selecting the best index or indexes to perform the task.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the first thing you will check for, if the query below is performing very slow?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;SELECT * FROM tblProducts ORDER BY UnitPrice ASC&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Check if there is an Index created on the UntiPrice column used in the ORDER BY clause. An index on the UnitPrice column can help the above query to find data very quickly.When we ask for a sorted data, the database will try to find an index and avoid sorting the results during execution of the query. We control sorting of a data by specifying a field, or fields, in an ORDER BY clause, with the sort order as ASC (ascending) or DESC (descending). &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;With no index, the database will scan the &lt;strong&gt;tblProducts&lt;/strong&gt; table and sort the rows to process the query. However, if there is an index, it can provide the database with a presorted list of prices. The database can simply scan the index from the first entry to the last entry and retrieve the rows in sorted order. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The same index works equally well with the following query, simply by scanning the index in reverse.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;SELECT * FROM tblProducts ORDER BY UnitPrice DESC &lt;/span&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the significance of an Index on the column used in the GROUP BY clause?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Creating an Index on the column, that is used in the &lt;strong&gt;&lt;span style="color: blue;"&gt;GROUP BY&lt;/span&gt;&lt;/strong&gt; clause, can greatly improve the perofrmance. We use a &lt;strong&gt;&lt;span style="color: blue;"&gt;GROUP BY&lt;/span&gt;&lt;/strong&gt; clause to group records and aggregate values, for example, counting the number of products with the same UnitPrice. To process a query with a GROUP BY clause, the database will often sort the results on the columns included in the GROUP BY. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The following query counts the number of products at each price by grouping together records with the same UnitPrice value.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: Arial, Helvetica, sans-serif;"&gt;SELECT UnitPrice, Count(*) FROM tblProducts GROUP BY UnitPrice &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The database can use the index (Index on &lt;strong&gt;UNITPRICE&lt;/strong&gt; column) to retrieve the prices in order. Since matching prices appear in consecutive index entries, the database is able to count the number of products at each price quickly. Indexing a field used in a &lt;strong&gt;&lt;span style="color: blue;"&gt;GROUP BY&lt;/span&gt;&lt;/strong&gt; clause can often speed up a query.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the role of an Index in maintaining a Unique column in table?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Columns requiring unique values (such as primary key columns) must have a unique index applied. There are several methods available to create a unique index. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1.&lt;/strong&gt; Marking a column as a primary key will automatically create a unique index on the column.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2.&lt;/strong&gt; We can also create a unique index by checking the Create UNIQUE checkbox when creating the index graphically. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3.&lt;/strong&gt; We can also create a unique index using SQL with the following command: &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;CREATE UNIQUE INDEX IDX_ProductName On Products (ProductName)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;The above SQL command will not allow any duplicate values in the ProductName column, and an index is the best tool for the database to use to enforce this rule. Each time an application adds or modifies a row in the table, the database needs to search all existing records to ensure none of values in the new data duplicate existing values.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-4576852895861778483?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/pv9pIFGuNE7JoGrWgrPkDZCTxcw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pv9pIFGuNE7JoGrWgrPkDZCTxcw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/pv9pIFGuNE7JoGrWgrPkDZCTxcw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/pv9pIFGuNE7JoGrWgrPkDZCTxcw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/trxaTXzjcuc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/4576852895861778483/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4576852895861778483?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/4576852895861778483?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/trxaTXzjcuc/sql-server-interview-questions-on.html" title="SQL Server Interview Questions on Indexes - Part 1" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUFQ3w_eSp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-222194607439148942</id><published>2011-05-07T01:20:00.000-07:00</published><updated>2012-01-22T09:43:32.241-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:43:32.241-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".net developers" /><category scheme="http://www.blogger.com/atom/ns#" term="dot net" /><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="dotnet" /><title>SQL Server Interview Questions</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt; &lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Basic SQL Server Interview Questions&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_2213.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;SQL Server Interview Questions on Temporary Tables&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;SQL Server Interview Questions on Indexes - Part 1&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_07.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;SQL Server Interview Questions on Indexes - Part 2&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-temporary.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;What is the difference between a Temporary Table and a Table Variable&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-use-of-coalesce-in-sql-server.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;What is the use of COALESCE in SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on_10.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;SQL Server Interview Questions on triggers&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt; &lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/what-is-difference-between-user-defined.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Difference between User Defined Function and Stored Procedure&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;SQL Server Interview Questions on Views - Part 1&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-on-views_16.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;SQL Server Interview Questions on Views - Part 2&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions-on.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Basic SQL Server Interview Questions on Joins&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/inner-join-with-example.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Explain Inner Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/left-join-with-example.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Explain Left Outer Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/right-outer-join-with-example.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Explain Right Outer Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/full-outer-join-in-sql-server-with.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Explain Full Outer Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/self-join-with-example.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;Explain Self Join with an example&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/difference-between-index-scan-and-index.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;What is the difference between Index Scan and Index Seek&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/07/advantages-of-stored-procedures.html"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; line-height: 160%; text-decoration: none;"&gt;What are the advantages of using stored procedures?&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-222194607439148942?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wSbdG5yLxWxef8V1Mp5OxInLLFg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wSbdG5yLxWxef8V1Mp5OxInLLFg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wSbdG5yLxWxef8V1Mp5OxInLLFg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wSbdG5yLxWxef8V1Mp5OxInLLFg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/0BAFZKiv6wU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/222194607439148942/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/222194607439148942?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/222194607439148942?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/0BAFZKiv6wU/sql-server-interview-questions.html" title="SQL Server Interview Questions" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>3</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEADRn8-fCp7ImA9WhRUEkg.&quot;"><id>tag:blogger.com,1999:blog-5562253332413822713.post-7533251102352848063</id><published>2011-05-06T14:56:00.000-07:00</published><updated>2012-01-22T09:19:37.154-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-22T09:19:37.154-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".net developers" /><category scheme="http://www.blogger.com/atom/ns#" term="dot net" /><category scheme="http://www.blogger.com/atom/ns#" term="sql server interview questions" /><category scheme="http://www.blogger.com/atom/ns#" term="dotnet" /><title>Basic SQL Server Interview Questions</title><content type="html">&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Explain DML, DDL, DCL and TCL statements with examples?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;DML&lt;/strong&gt;: DML stands for Data Manipulation Language. DML is used to retrieve, store, modify, delete, insert and update data in database.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Examples &lt;/strong&gt;of DML statements: SELECT, UPDATE, INSERT, DELETE statements.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;DDL&lt;/strong&gt;: DDL stands for Data Definition Language. DDL is used to create and modify the structure of database objects.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Examples&lt;/strong&gt;: CREATE, ALTER, DROP statements.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;DCL&lt;/strong&gt;: DCL stands for Data Control Language. DCL is used to create roles, grant and revoke permissions, establish referential integrity etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Examples&lt;/strong&gt;: GRANT, REVOKE statements&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;TCL&lt;/strong&gt;: TCL stands for Transactional Control Language. TCL is used to manage transactions within a database.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Examples&lt;/strong&gt;: COMMIT, ROLLBACK statements&lt;/span&gt;&lt;br /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-5905727831268054";
/* 336x280, created 5/3/11 */
google_ad_slot = "6179544304";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;What is the difference between Drop, Delete and Truncate statements in SQL Server?&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Drop, Delete and Truncate&lt;/strong&gt; - All operations can be rolled back.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Delete &lt;/strong&gt;is a logged operation, which means deleted rows are written to the transaction log.&lt;strong&gt;Truncate&lt;/strong&gt; is not a logged operation, which means deleted rows are not written to the transaction log. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Hence, truncate is a little faster than Delete&lt;/strong&gt;. You can have a where clause in Delete statement where as Truncate statement cannot have a where clause. Truncate will delete all the rows in a Table, but the structure of the table remains. Drop would delete all the rows including the structure of the Table.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Please refer to the screen shot below for the differences summary snapshot between Drop, Delete and Truncate statements in SQL Server.&lt;/span&gt;&lt;br /&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="align: left;"&gt;&lt;br /&gt;
&lt;img border="1"  src="http://1.bp.blogspot.com/-D6vcPgujroo/TffVCroxJPI/AAAAAAAAAHY/Y1jlyzR5klU/s400/Drop-Delete-Truncate.png" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;strong&gt;What is Cascading referential integrity constraint?&lt;/strong&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Cascading referential integrity constraints&lt;/strong&gt; allow you to define the actions Microsoft SQL Server should take when a user attempts to delete or update a key to which an existing foreign keys point.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;br /&gt;
You can instruct SQL Server to do the following:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;1. No Action:&lt;/strong&gt; This is the default behaviour. No Action specifies that if an attempt is made to delete or update a row with a key referenced by foreign keys in existing rows in other tables, an error is raised and the DELETE or UPDATE is rolled back.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;2. Cascade:&lt;/strong&gt; Specifies that if an attempt is made to delete or update a row with a key referenced by foreign keys in existing rows in other tables, all rows containing those foreign keys are also deleted or updated.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;3. Set NULL:&lt;/strong&gt; Specifies that if an attempt is made to delete or update a row with a key referenced by foreign keys in existing rows in other tables, all rows containing those foreign keys are set to NULL.&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;4. Set Default:&lt;/strong&gt; Specifies that if an attempt is made to delete or update a row with a key referenced by foreign keys in existing rows in other tables, all rows containing those foreign keys are set to default values.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;DIfference between primary key and unique key in SQL Server?&lt;/strong&gt;&lt;br /&gt;
1. A table can have only one primary key. On the other hand a table can have more than one unique key.&lt;br /&gt;
2. Primary key column does not accept any null values, where as a unique key column accept one null value.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table style="border: 1px solid black;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://venkataspinterview.blogspot.com/2011/05/aspnet-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;ASP.NET&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatcsharpinterview.blogspot.com/2011/05/c-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;CSharp&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://venkatsqlinterview.blogspot.com/2011/05/sql-server-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;SQL Server&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td style="line-height: 15px; padding-top: 5px; width: 180px;"&gt;&lt;br /&gt;
&lt;span style="color: black; font-family: Arial; line-height: 160%; text-decoration: underline;"&gt;All Questions&lt;/span&gt;&lt;br /&gt;
&lt;a href="http://wcfinterviewquestions.blogspot.com/2011/05/wcf-interview-questions-by-topic.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 180%; padding-left: 0px; text-decoration: underline;"&gt;WCF&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://mvcquestions.blogspot.com/2011/11/mvc-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;MVC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://hrinterviewquestions.blogspot.com/2011/05/hr-interview-questions.html"&gt;&lt;span style="color: #0066cc; font-family: Arial; font-size: 11pt; line-height: 160%; padding-left: 1px; text-decoration: underline;"&gt;HR Round&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #0066cc; font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="font-size: 11px; line-height: 15px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;td&gt;&lt;script type="text/javascript"&gt;
&lt;!--
            google_ad_client = "pub-5905727831268054";
            /* 5LinksLinkUnit */
            google_ad_slot = "3463876315";
            google_ad_width = 160;
            google_ad_height = 90;
//--&gt;
&lt;/script&gt;&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="height: 60px;"&gt;&lt;td colspan="3" style="border-top: 1px solid black; color: black; font-family: Arial; font-size: 13pt; font-weight: bold; text-align: center;"&gt;Search This Site &lt;form action="http://venkataspinterview.blogspot.com/2011/06/search-results.html" id="cse-search-box"&gt;&lt;div&gt;&lt;input name="cx" type="hidden" value="partner-pub-5905727831268054:nx4lrbyuk8j" /&gt;&lt;input name="cof" type="hidden" value="FORID:11" /&gt;&lt;input name="ie" type="hidden" value="ISO-8859-1" /&gt;&lt;input name="q" size="40" type="text" /&gt;&lt;input name="sa" type="submit" value="Search" /&gt;&lt;/div&gt;&lt;/form&gt;&lt;script src="http://www.google.com/cse/brand?form=cse-search-box&amp;amp;lang=en" type="text/javascript"&gt;
&lt;/script&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5562253332413822713-7533251102352848063?l=venkatsqlinterview.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/YUPeRfP4Lz2buq6IpAWbxwpzj2c/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YUPeRfP4Lz2buq6IpAWbxwpzj2c/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/YUPeRfP4Lz2buq6IpAWbxwpzj2c/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YUPeRfP4Lz2buq6IpAWbxwpzj2c/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/YpXCj/~4/N7er-StGBrU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://venkatsqlinterview.blogspot.com/feeds/7533251102352848063/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions.html#comment-form" title="12 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7533251102352848063?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5562253332413822713/posts/default/7533251102352848063?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/YpXCj/~3/N7er-StGBrU/basic-sql-server-interview-questions.html" title="Basic SQL Server Interview Questions" /><author><name>Venkat</name><uri>http://www.blogger.com/profile/11295753737388828672</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-D6vcPgujroo/TffVCroxJPI/AAAAAAAAAHY/Y1jlyzR5klU/s72-c/Drop-Delete-Truncate.png" height="72" width="72" /><thr:total>12</thr:total><feedburner:origLink>http://venkatsqlinterview.blogspot.com/2011/05/basic-sql-server-interview-questions.html</feedburner:origLink></entry></feed>

