<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Journey to SQL Authority with Pinal Dave &#187; SQL Interview Questions and Answers</title>
	<atom:link href="http://blog.sqlauthority.com/category/sql-interview-questions-and-answers/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 01:30:19 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='blog.sqlauthority.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/08e35387c05b61340e885b1763a69d9f?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Journey to SQL Authority with Pinal Dave &#187; SQL Interview Questions and Answers</title>
		<link>http://blog.sqlauthority.com</link>
	</image>
			<item>
		<title>SQL SERVER &#8211; Stored Procedure are Compiled on First Run &#8211; SP taking Longer to Run First Time</title>
		<link>http://blog.sqlauthority.com/2009/11/08/sql-server-stored-procedure-are-compiled-on-first-run-sp-taking-longer-to-run-first-time/</link>
		<comments>http://blog.sqlauthority.com/2009/11/08/sql-server-stored-procedure-are-compiled-on-first-run-sp-taking-longer-to-run-first-time/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 01:30:34 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Stored Procedure]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[SQL Cache]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7164</guid>
		<description><![CDATA[During the PASS summit, one of the attendees asked me the following question.
Why the Stored Procedure takes long time to run for first time?
The reason for the same is because Stored Procedures are compiled when it runs first time. When I answered the same, he replied that Stored Procedures are pre-compiled, and this should not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=7164&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">During the PASS summit, one of the attendees asked me the following question.</p>
<p style="text-align:justify;"><strong><em>Why the Stored Procedure takes long time to run for first time?</em></strong></p>
<p style="text-align:justify;"><strong>The reason for the same is because Stored Procedures are compiled when it runs first time. </strong>When I answered the same, he replied that Stored Procedures are pre-compiled, and this should not be the case. In fact, Stored Procedures are not pre-compiled; they compile only during their first time execution.</p>
<p style="text-align:justify;">There is a misconception that stored procedures are pre-compiled. They are not pre-compiled, but compiled only during the first run. For every subsequent runs, it is for sure pre-compiled.</p>
<p style="text-align:justify;">If you create any SP, you will find that there is no cache entry for the execution of that SP.</p>
<p style="text-align:justify;">After running the SP for the first time, the entry for the cache is made in the system.</p>
<p style="text-align:justify;">If we see the following script, we can notice the different of cache when SP was created and SP was executed.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:green;">/* Exeercise to verify if stored procedure pre-compiled */<br />
</span><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks<br />
GO<br />
</span><span style="color:green;">-- Clean Cache<br />
</span><span style="color:blue;">DBCC </span><span style="color:black;">FREEPROCCACHE<br />
GO<br />
</span><span style="color:blue;">IF </span><span style="color:gray;">EXISTS (</span><span style="color:blue;">SELECT </span><span style="color:gray;">* </span><span style="color:blue;">FROM </span><span style="color:black;">sys.objects </span><span style="color:blue;">WHERE </span><span style="color:magenta;">OBJECT_ID </span><span style="color:blue;">= </span><span style="color:magenta;">OBJECT_ID</span><span style="color:gray;">(</span><span style="color:red;">N'[dbo].[CompSP]'</span><span style="color:gray;">) AND </span><span style="color:black;">type </span><span style="color:blue;">IN </span><span style="color:gray;">(</span><span style="color:red;">N'P'</span><span style="color:gray;">, </span><span style="color:red;">N'PC'</span><span style="color:gray;">))<br />
</span><span style="color:blue;">DROP PROCEDURE </span><span style="color:black;">[dbo].[CompSP]<br />
GO<br />
</span><span style="color:green;">-- Create New Stored Procedure<br />
</span><span style="color:blue;">CREATE PROCEDURE </span><span style="color:black;">CompSP<br />
</span><span style="color:blue;">AS<br />
SELECT </span><span style="color:gray;">*<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">HumanResources.Department<br />
GO<br />
</span><span style="color:green;">-- Check the Query Plan for SQL Batch<br />
-- You will find that there is no ObjectName with CompSP<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">cp.objtype </span><span style="color:blue;">AS </span><span style="color:black;">PlanType</span><span style="color:gray;">,<br />
</span><span style="color:magenta;">OBJECT_NAME</span><span style="color:gray;">(</span><span style="color:black;">st.objectid</span><span style="color:gray;">,</span><span style="color:black;">st.dbid</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">ObjectName</span><span style="color:gray;">,<br />
</span><span style="color:black;">cp.refcounts </span><span style="color:blue;">AS </span><span style="color:black;">ReferenceCounts</span><span style="color:gray;">,<br />
</span><span style="color:black;">cp.usecounts </span><span style="color:blue;">AS </span><span style="color:black;">UseCounts</span><span style="color:gray;">,<br />
</span><span style="color:black;">st.</span><span style="color:blue;">TEXT AS </span><span style="color:black;">SQLBatch</span><span style="color:gray;">,<br />
</span><span style="color:black;">qp.query_plan </span><span style="color:blue;">AS </span><span style="color:black;">QueryPlan<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">sys.dm_exec_cached_plans </span><span style="color:blue;">AS </span><span style="color:black;">cp<br />
</span><span style="color:gray;">CROSS </span><span style="color:black;">APPLY sys.dm_exec_query_plan</span><span style="color:gray;">(</span><span style="color:black;">cp.plan_handle</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">qp<br />
</span><span style="color:gray;">CROSS </span><span style="color:black;">APPLY sys.dm_exec_sql_text</span><span style="color:gray;">(</span><span style="color:black;">cp.plan_handle</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">st</span><span style="color:gray;">;<br />
</span><span style="color:black;">GO<br />
</span><span style="color:green;">/* Execute Stored Procedure */<br />
</span><span style="color:blue;">EXEC </span><span style="color:black;">CompSP<br />
GO<br />
</span><span style="color:green;">-- Check the Query Plan for SQL Batch<br />
-- You will find that there is one entry with name ObjectName with name CompSP<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">cp.objtype </span><span style="color:blue;">AS </span><span style="color:black;">PlanType</span><span style="color:gray;">,<br />
</span><span style="color:magenta;">OBJECT_NAME</span><span style="color:gray;">(</span><span style="color:black;">st.objectid</span><span style="color:gray;">,</span><span style="color:black;">st.dbid</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">ObjectName</span><span style="color:gray;">,<br />
</span><span style="color:black;">cp.refcounts </span><span style="color:blue;">AS </span><span style="color:black;">ReferenceCounts</span><span style="color:gray;">,<br />
</span><span style="color:black;">cp.usecounts </span><span style="color:blue;">AS </span><span style="color:black;">UseCounts</span><span style="color:gray;">,<br />
</span><span style="color:black;">st.</span><span style="color:blue;">TEXT AS </span><span style="color:black;">SQLBatch</span><span style="color:gray;">,<br />
</span><span style="color:black;">qp.query_plan </span><span style="color:blue;">AS </span><span style="color:black;">QueryPlan<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">sys.dm_exec_cached_plans </span><span style="color:blue;">AS </span><span style="color:black;">cp<br />
</span><span style="color:gray;">CROSS </span><span style="color:black;">APPLY sys.dm_exec_query_plan</span><span style="color:gray;">(</span><span style="color:black;">cp.plan_handle</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">qp<br />
</span><span style="color:gray;">CROSS </span><span style="color:black;">APPLY sys.dm_exec_sql_text</span><span style="color:gray;">(</span><span style="color:black;">cp.plan_handle</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">st</span><span style="color:gray;">;<br />
</span><span style="color:black;">GO</span></code></p>
<p style="text-align:justify;">The result set of above query is as following.</p>
<p style="text-align:justify;"><img class="alignnone" src="http://www.pinaldave.com/bimg/SPComp.jpg" alt="" width="500" height="396" /></p>
<p style="text-align:justify;">The above script to find out the cache is taken from the white paper <a href="http://blog.sqlauthority.com/2009/08/29/sql-server-plan-caching-in-sql-server-2008-by-greg-low/" target="_blank"><strong>SQL SERVER – Plan Caching in SQL Server 2008 by Greg Low</strong></a>. You can also read my follow up article <a href="http://blog.sqlauthority.com/2009/09/14/sql-server-plan-caching-and-schema-change-an-interesting-observation/" target="_blank"><strong>SQL SERVER – Plan Caching and Schema Change – An Interesting Observation</strong></a>, where I have given an interesting conversation with Greg Low.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (</strong><a href="http://blog.sqlauthority.com/" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Query, SQL Scripts, SQL Server, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology Tagged: SQL Cache <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/7164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/7164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/7164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/7164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/7164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/7164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/7164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/7164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/7164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/7164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=7164&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2009/11/08/sql-server-stored-procedure-are-compiled-on-first-run-sp-taking-longer-to-run-first-time/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/SPComp.jpg" medium="image" />
	</item>
		<item>
		<title>SQLAuthority News &#8211; Beyond Relational Interview on SQL Server 2008 Beyond Relational</title>
		<link>http://blog.sqlauthority.com/2009/08/18/sqlauthority-news-beyond-relational-interview-on-sql-server-2008-beyond-relational/</link>
		<comments>http://blog.sqlauthority.com/2009/08/18/sqlauthority-news-beyond-relational-interview-on-sql-server-2008-beyond-relational/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 01:30:40 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQLAuthority News]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Beyond Relational]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6614</guid>
		<description><![CDATA[SQL Server MVP and my personal friend Jacob Sebastian has published my interview on subject of Beyond Relational on his famous site Beyond Relational. Jacob is quite known for his T-SQL challenges as well. If you have not ever tried one, I suggest you give it a try and you will be addicted to it.
Beyond [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=6614&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">SQL Server MVP and my personal friend <strong>Jacob Sebastian</strong> has published my interview on subject of Beyond Relational on his famous site <strong><a href="http://beyondrelational.com/blogs/br/archive/2009/08/11/beyond-relational-interview-pinal-dave-speaks-on-sql-server-2008-beyond-relational.aspx" target="_blank">Beyond Relational</a></strong>. Jacob is quite known for his <strong><a href="http://beyondrelational.com/blogs/tc/" target="_blank">T-SQL challenges</a></strong> as well. If you have not ever tried one, I suggest you give it a try and you will be addicted to it.</p>
<p style="text-align:justify;">Beyond Relational is interesting term. In simple terms, this means that it is beyond relations to traditional RDBMS. There are so many things to talk about when we stop thinking in terms of relationals. When we say “beyond relationals”, this does not mean that we move away from the relational database. In fact, for me words suggest quite the opposite; they imply strong ties to relational databases. It would not be termed “beyond” if it had nothing to do with relationals. The science of “beyond relational” picks up relationals where traditional RDBMS stop.</p>
<p style="text-align:justify;">Please read <a href="http://beyondrelational.com/blogs/br/archive/2009/08/11/beyond-relational-interview-pinal-dave-speaks-on-sql-server-2008-beyond-relational.aspx" target="_blank"><strong>my complete interview here</strong> </a>and let me know what you think about <strong>Beyond Relational</strong>.</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.sqlauthority.com/" target="_blank"><strong>http://blog.sqlauthority.com</strong></a><strong>)</strong></p>
<p style="text-align:justify;">
<p style="text-align:justify;">
Posted in Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology Tagged: Beyond Relational <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/6614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/6614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/6614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/6614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/6614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/6614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/6614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/6614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/6614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/6614/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=6614&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2009/08/18/sqlauthority-news-beyond-relational-interview-on-sql-server-2008-beyond-relational/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQLAuthority News &#8211; Interview with SQL Server MVP Glenn Berry</title>
		<link>http://blog.sqlauthority.com/2009/08/09/sqlauthority-news-interview-with-sql-server-mvp-glenn-berry/</link>
		<comments>http://blog.sqlauthority.com/2009/08/09/sqlauthority-news-interview-with-sql-server-mvp-glenn-berry/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 01:30:33 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MVP]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQLAuthority News]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=6500</guid>
		<description><![CDATA[Glenn Berry works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS. He is also an Adjunct Faculty member at University College &#8211; University of Denver, where he has been teaching since [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=6500&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;"><strong><img class="alignleft" style="margin:5px;" src="http://www.pinaldave.com/bimg/GlennBerry.jpg" alt="" width="200" height="258" />Glenn Berry</strong> works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS. He is also an Adjunct Faculty member at University College &#8211; University of Denver, where he has been teaching since 2000. He is one wonderful blogger and often blogs at <strong><a href="http://glennberrysqlperformance.spaces.live.com" target="_blank">here</a></strong>.</p>
<p style="text-align:justify;"><strong>1) Please tell us something about yourself.</strong><br />
I have been working as a Database Architect at NewsGator Technologies for about 3.5 years. Before that, I worked as a Performance Architect at a company called Mortgage Cadence for about four years.  I have also been teaching SQL Server classes  at night at University of Denver &#8211; University College for ten years. I have a couple of miniature Dachshunds, who are like my children.</p>
<p style="text-align:justify;"><strong>2) We all know that you work as NewsGator, tell us something about your prime responsibility?</strong><br />
Well, my job title is Database Architect, but I am really the only database type person in the entire company. I pretty much have to do it all, from designing our architecture to writing stored procedures, to making sure our backup jobs are running. The good thing about that is that I get to stay hands on with SQL Server, which I really enjoy.</p>
<p style="text-align:justify;"><strong>3) What would you like to call yourself &#8211; a Production DBA, a Database Architecture, A Database Developer or something else?</strong><br />
I end up doing both Database Development and Database Administration, along with the overall architecture. I call myself a Database Architect because it seems like the best overall description.</p>
<p style="text-align:justify;"><strong>4) What is the largest size of database you have handled and what was your role with that database?</strong><br />
Our largest database is about 4TB (after Page Compression in SQL Server 2008). We currently have about 8TB of data between all of our production SQL Server instances.</p>
<p style="text-align:justify;"><strong>5)  NewsGator must have TB of data and millions of transactions a min. Would you please tell something about infrastructure?</strong><br />
We have about 8TB of data, which is really not that large by SQL Server 2008 standards. We are using pretty low-end, commodity hardware (no HP Superdomes here!). We are running completely on SQL Server 2008 in Production since February 2009. We were in the Katmai Technology Assistance Program (TAP), which was a private, external beta for SQL Server 2008, which helped us get a head start on getting SQL Server 2008 deployed very quickly.  We are using Windows Server 2008 for all of our database servers, and we have had very good luck with that.
</p>
<p style="text-align:justify;">We have to run 24 x 7 x 365, with no regular maintenance windows. Because of this, we are using database mirroring on all of our mission critical databases, which works very well for us. We even used database mirroring to upgrade each of our production SQL Server 2005 databases to SQL Server 2008 with less than 30 second outages.</p>
<p style="text-align:justify;"><strong>6) Tell us 3 most important tips for SQL Server.</strong><br />
It is very important to know your environment and workload (from a SQL Server perspective). That way, you will recognize when something has changed, and you will be able to make better decisions in a crisis situation. It is also important to stay current with what is going on with the latest hardware (I read tech enthusiast sites like AnandTech and Tom&#8217;s Hardware), so that you can do a good job selecting and sizing hardware. Too many DBAs just blindly trust their I.T. department to select hardware.</p>
<p style="text-align:justify;"><strong>7) People call you the most friendliest MVP of all. Why?</strong><br />
I do know a lot of the other SQL MVP&#8217;s, and I guess that I have managed to avoid offending anyone so far. I was recently renewed for my third year as a SQL MVP, so I must be doing something right. I was lucky enough to be chosen to present two Community Sessions at this year&#8217;s PASS summit, so hopefully I will meet many more SQL Server people in the future.</p>
<p style="text-align:justify;"><strong>8) Tell us something about yourself, which is not commonly known.</strong><br />
I like to read military history and science fiction. Long ago, I was a Sergeant in the United States Marine Corps. I was a tank commander in an M60A1 Rise\Passive tank. I think that military experience is very useful for a DBA, since it helps teach you to be disciplined, detail-oriented, and prepared for anything.</p>
<div class="mceTemp" style="text-align:justify;">
<dl class="wp-caption alignnone">
<dt class="wp-caption-dt"><img title="Indian MVPs, Glenn Berry" src="http://www.pinaldave.com/bimg/MVPSummit/DSC03501.jpg" alt="" width="500" height="375" /></dt>
<dd class="wp-caption-dd">Indian MVPs, Glenn Berry</dd>
</dl>
</div>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.SQLAuthority.com</a>)</strong></p>
Posted in Database, MVP, Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/6500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/6500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/6500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/6500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/6500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/6500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/6500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/6500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/6500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/6500/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=6500&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2009/08/09/sqlauthority-news-interview-with-sql-server-mvp-glenn-berry/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/GlennBerry.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/MVPSummit/DSC03501.jpg" medium="image">
			<media:title type="html">Indian MVPs, Glenn Berry</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; What is Interim Table &#8211; Simple Definition of Interim Table</title>
		<link>http://blog.sqlauthority.com/2009/06/04/sql-server-what-is-interim-table-simple-definition-of-interim-table/</link>
		<comments>http://blog.sqlauthority.com/2009/06/04/sql-server-what-is-interim-table-simple-definition-of-interim-table/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 01:30:54 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[Readers Question]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQLServer]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=5384</guid>
		<description><![CDATA[Sometimes a simple question like &#8220;What is interim table?&#8221; can initiate a never-ending discussion between developers. I experienced this recently while I was on phone helping my friends working in Los Angeles. In a conference call, one of the developers kept on talking about &#8220;first interim table&#8221; and &#8220;second interim table&#8221; and so forth, while [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=5384&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Sometimes a simple question like &#8220;<strong>What is interim table?</strong>&#8221; can initiate a never-ending discussion between developers. I experienced this recently while I was on phone helping my friends working in Los Angeles. In a conference call, one of the developers kept on talking about &#8220;first interim table&#8221; and &#8220;second interim table&#8221; and so forth, while another developer was of the opinion that that there cannot be more than one interim table. Well, as this was not enough a third developer interrupted the debate and said that all the tables are interim tables. The heated discussion seemed never ending.</p>
<p style="text-align:justify;">To put the long story sort, let us today in this blog post try to understand what interim table is and how many possible interim tables are there.</p>
<p style="text-align:justify;">Interim table is a table that is generated by joining two tables and not the final result table. In other words, when two tables are joined they create an interim table as resultset but the resultset is not final yet. It may be possible that more tables are about to join on the interim table, and more operations are still to be applied on that table (e.g. Order By, Having etc). Besides, it may be possible that there is no interim table; sometimes final table is what is generated when query is run.</p>
<p style="text-align:justify;">Let us try to comprehend the above explanation with an example using the following AdventureWorks sample database.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks</span><span style="color:gray;">;<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">SELECT </span><span style="color:gray;">*<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">Person.Contact C<br />
</span><span style="color:blue;">INNER JOIN </span><span style="color:black;">Sales.SalesPerson SP<br />
</span><span style="color:blue;">ON </span><span style="color:black;">C.ContactID </span><span style="color:blue;">= </span><span style="color:black;">SP.SalesPersonID<br />
</span><span style="color:blue;">INNER JOIN </span><span style="color:black;">Sales.SalesTerritory ST<br />
</span><span style="color:blue;">ON </span><span style="color:black;">ST.TerritoryID </span><span style="color:blue;">= </span><span style="color:black;">SP.TerritoryID<br />
</span><span style="color:blue;">ORDER BY </span><span style="color:black;">ST.TerritoryID</span><span style="color:gray;">, </span><span style="color:black;">C.LastName<br />
GO</span></code>
</p>
<p style="text-align:justify;"><span style="color:black;"><strong>First Interim Table:</strong></span></p>
<p style="text-align:justify;">When two tables are joined and there are more pending operations then the table is called first interim table.</p>
<p style="text-align:justify;"><span style="color:black;"><img class="alignnone" src="http://www.pinaldave.com/bimg/intrim1.jpg" alt="" width="500" height="466" /></span></p>
<p style="text-align:justify;"><span style="color:black;"><strong>Second InterimTable:</strong></span></p>
<p style="text-align:justify;">When a third table is joined to the first interim table and there are more pending operations then the table is called second interim table.</p>
<p style="text-align:justify;"><span style="color:black;"><img class="alignnone" src="http://www.pinaldave.com/bimg/intrim2.jpg" alt="" width="501" height="461" /></span></p>
<p style="text-align:justify;"><span style="color:black;"><strong>Final Table:</strong></span></p>
<p style="text-align:justify;">After joins, all the remaining database operations are performed on the latest interim table which generates the final table.</p>
<p style="text-align:justify;"><span style="color:black;"><img class="alignnone" src="http://www.pinaldave.com/bimg/intrim3.jpg" alt="" width="500" height="466" /></span></p>
<p style="text-align:justify;">Please let me know if your doubts about interim tables are clear now with this simple and easy-to-read post. If you like the style of this post, I will post many more like this in near future.</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.sqlauthority.com/" target="_blank"><strong>http://blog.sqlauthority.com</strong></a><strong>)</strong></p>
Posted in Pinal Dave, Readers Question, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQLServer, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/5384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/5384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/5384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/5384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/5384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/5384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/5384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/5384/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/5384/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/5384/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=5384&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2009/06/04/sql-server-what-is-interim-table-simple-definition-of-interim-table/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/intrim1.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/intrim2.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/intrim3.jpg" medium="image" />
	</item>
		<item>
		<title>SQLAuthority News &#8211; Interview of Author on 60 Seconds with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2009/04/25/sqlauthority-news-interview-of-author-on-60-seconds-with-pinal-dave/</link>
		<comments>http://blog.sqlauthority.com/2009/04/25/sqlauthority-news-interview-of-author-on-60-seconds-with-pinal-dave/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 01:30:18 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[About Me]]></category>
		<category><![CDATA[MVP]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQLAuthority News]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4542</guid>
		<description><![CDATA[Vijaya Kadiyala is my fellow .NET and SQL Expert and very respected member of the technology community in India. He is known for his easy but to the point attitude for technology. He regularly writes on his blog : DotNetVJ. I happen to meet him at MVP Summit in Seattle and have learned a lot [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=4542&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;"><a href="http://www.dotnetvj.com/" target="_blank"><strong>Vijaya Kadiyala</strong></a> is my fellow .NET and SQL Expert and very respected member of the technology community in India. He is known for his easy but to the point attitude for technology. He regularly writes on his blog : <strong><a href="http://www.dotnetvj.com/" target="_blank">DotNetVJ</a></strong>. I happen to meet him at MVP Summit in Seattle and have learned a lot about him. In my recent travel to South India, I have learned a great deal about his community services and enthusiasm about cutting edge technology.</p>
<p style="text-align:justify;">Vijaya has started interview series on his blog where he takes very quick interviews of community leaders. He asked following five questions in his interview series of <strong>60 Seconds</strong>.</p>
<ol style="text-align:justify;">
<li>Please tell us something about yourself.</li>
<li>What motivated you to become an MVP.</li>
<li>Please share with us your journey of becoming an MVP.</li>
<li>Tell us about your MVP Summit experience.</li>
<li>Any message to the Technologists.</li>
</ol>
<p style="text-align:justify;">It was my honor as expert like Vijaya has asked for my interview. Read my answers to Vijaya&#8217;s question on his blog.</p>
<h3 style="text-align:justify;">Read <strong><a href="http://www.dotnetvj.com/2009/04/60-seconds-with-pinal-dave.html" target="_blank">60 Seconds with Pinal Dave</a></strong>.</h3>
<p style="text-align:justify;">Vijaya is also planning to write book, and poll aobut his book is open on his blog. I strongly urge all my readers to participate for the same.</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.SQLAuthority.com</a>)</strong></p>
Posted in About Me, MVP, Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/4542/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/4542/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/4542/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/4542/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/4542/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/4542/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/4542/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/4542/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/4542/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/4542/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=4542&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2009/04/25/sqlauthority-news-interview-of-author-on-60-seconds-with-pinal-dave/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQLAuthority News &#8211; Author Video Interview Published Online &#8211; Microsoft MVP Summit 2009</title>
		<link>http://blog.sqlauthority.com/2009/03/27/sqlauthority-news-author-video-interview-published-online-microsoft-mvp-summit-2009/</link>
		<comments>http://blog.sqlauthority.com/2009/03/27/sqlauthority-news-author-video-interview-published-online-microsoft-mvp-summit-2009/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 01:30:25 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[About Me]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MVP]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQLAuthority News]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[MVP Summit 2009]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=4101</guid>
		<description><![CDATA[Microsoft MVP Award Blog and Microsoft South Asian MVP Blog has published my video interview online. My interview was conducted by Abhishek Kant &#8211; Microsoft MVP Lead and Technology Blogger. I am thankful to Abhishek Kant for conducting my interview, Abhishek Baxi for publishing on South Asian Blog and Jas Dhaliwal for producing the video. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=4101&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Microsoft MVP Award Blog and <a href="http://blogs.technet.com/southasiamvp/archive/2009/03/26/2009-mvp-global-summit-an-mvp-interview.aspx" target="_blank">Microsoft South Asian MVP Blog</a> has published my video interview online. My interview was conducted by Abhishek Kant &#8211; Microsoft MVP Lead and Technology Blogger. I am thankful to <strong><a href="http://www.abhishekkant.net/" target="_blank">Abhishek Kant</a></strong> for conducting my interview, <strong><a href="http://www.baxiabhishek.info/" target="_blank">Abhishek Baxi</a></strong> for publishing on South Asian Blog and <strong><a href="http://www.jasdhaliwal.com/" target="_blank">Jas Dhaliwal</a></strong> for producing the video. Above All I am very thankful to Microsoft for awarding me MVP Award. This video was shot at <a href="http://www.sqlservercentral.com/blogs/steve_jones/archive/2009/03/05/the-mvp-summit-wrapup.aspx" target="_blank">Microsoft MVP Summit 2009</a> at Seattle.</p>
<p style="text-align:justify;"><strong><a href="http://blogs.msdn.com/mvpawardprogram/archive/2009/03/26/2009-mvp-global-summit-week-mvp-interviews-part-4.aspx" target="_blank">Watch my Video on Microsoft MVP Award Blog</a></strong></p>
<p style="text-align:justify;"><strong><a href="http://blogs.technet.com/southasiamvp/archive/2009/03/26/2009-mvp-global-summit-an-mvp-interview.aspx">Watch my Video on Microsoft South Asian MVP Blog</a></strong></p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p>
<p style="text-align:justify;"><strong><br />
</strong>
</p>
<p style="text-align:justify;">
<p style="text-align:justify;">
Posted in About Me, Database, MVP, Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology Tagged: MVP Summit 2009 <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/4101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/4101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/4101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/4101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/4101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/4101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/4101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/4101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/4101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/4101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=4101&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2009/03/27/sqlauthority-news-author-video-interview-published-online-microsoft-mvp-summit-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; T-SQL Script for FizzBuzz Logic</title>
		<link>http://blog.sqlauthority.com/2009/02/02/sql-server-t-sql-script-for-fizzbuzz-logic/</link>
		<comments>http://blog.sqlauthority.com/2009/02/02/sql-server-t-sql-script-for-fizzbuzz-logic/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 01:30:08 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Puzzle]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2233</guid>
		<description><![CDATA[Following is quite common Interview Question asked in many interview questions. FizzBuzz is popular but very simple puzzle and have been very popular to solve. FizzBuzz problem can be attempted in any programming language. Let us attempt it in T-SQL.
Definition of FizzBuzz Puzzle : Write a program that prints the numbers from 1 to 100. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=2233&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Following is quite common Interview Question asked in many interview questions. FizzBuzz is popular but very simple puzzle and have been very popular to solve. FizzBuzz problem can be attempted in any programming language. Let us attempt it in T-SQL.</p>
<p style="text-align:justify;"><strong>Definition of FizzBuzz Puzzle</strong> : Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">DECLARE </span><span style="color:#434343;">@counter </span><span style="color:blue;">INT<br />
DECLARE </span><span style="color:#434343;">@output </span><span style="color:blue;">VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">8</span><span style="color:gray;">)<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@counter </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">WHILE </span><span style="color:#434343;">@counter </span><span style="color:gray;">&lt; </span><span style="color:black;">101<br />
</span><span style="color:blue;">BEGIN<br />
SET </span><span style="color:#434343;">@output </span><span style="color:blue;">= </span><span style="color:red;">''<br />
</span><span style="color:blue;">IF </span><span style="color:#434343;">@counter </span><span style="color:gray;">% </span><span style="color:black;">3 </span><span style="color:blue;">= </span><span style="color:black;">0<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@output </span><span style="color:blue;">= </span><span style="color:red;">'Fizz'<br />
</span><span style="color:blue;">IF </span><span style="color:#434343;">@counter </span><span style="color:gray;">% </span><span style="color:black;">5 </span><span style="color:blue;">= </span><span style="color:black;">0<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@output </span><span style="color:blue;">= </span><span style="color:#434343;">@output </span><span style="color:gray;">+ </span><span style="color:red;">'Buzz'<br />
</span><span style="color:blue;">IF </span><span style="color:#434343;">@output </span><span style="color:blue;">= </span><span style="color:red;">''<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@output </span><span style="color:blue;">= </span><span style="color:#434343;">@counter<br />
</span><span style="color:blue;">PRINT </span><span style="color:#434343;">@output<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@counter </span><span style="color:blue;">= </span><span style="color:#434343;">@counter </span><span style="color:gray;">+ </span><span style="color:black;">1<br />
</span><span style="color:blue;">END</span></code>
</p>
<p style="text-align:justify;"><img class="alignnone" src="http://www.pinaldave.com/bimg/fizzbuzz.jpg" alt="" width="274" height="571" /></p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Puzzle, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/2233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/2233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/2233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/2233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/2233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/2233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/2233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/2233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/2233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/2233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=2233&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2009/02/02/sql-server-t-sql-script-for-fizzbuzz-logic/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/fizzbuzz.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Interesting Interview Questions &#8211; Revisited</title>
		<link>http://blog.sqlauthority.com/2008/12/17/sql-server-interesting-interview-questions-revisited/</link>
		<comments>http://blog.sqlauthority.com/2008/12/17/sql-server-interesting-interview-questions-revisited/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:30:00 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[Readers Contribution]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Puzzle]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1754</guid>
		<description><![CDATA[I really enjoyed users participation in my previous question. Read SQL SERVER &#8211; Interesting Interview Questions before continuing reading this article. This interview question was about user participation and about how good and how different you can come with your T-SQL script. What I really liked is that many users took this test seriously and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1754&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">I really enjoyed users participation in my previous question. Read <strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/" target="_blank">SQL SERVER &#8211; Interesting Interview Questions</a></strong> before continuing reading this article. This interview question was about user participation and about how good and how different you can come with your T-SQL script. What I really liked is that many users took this test seriously and did their best to answer. I really want to congratulate all the readers who have attempted to answer this question.</p>
<p style="text-align:justify;">As I have said earlier it did not matter what is the database structure, but it mattered what should be the good database architecture design. Here it only mattered if you can write T-SQL based on question.</p>
<p style="text-align:justify;">Following readers have got correct answer.</p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44580" target="_blank">Zod</a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44584" target="_blank">Eric</a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44598" target="_blank">Imran Mohammed</a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44605" target="_blank">bhadeliaimran</a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44607" target="_blank">fly</a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44629" target="_blank">pom</a></p>
<p style="text-align:justify;">I really want to thank and congratulate readers who have answered this question correct. I would suggest that you book mark this article as well original article for your personal reference. In future if you need ever recommendation regarding any interview I will be happy to list this articles for you in reference.</p>
<p style="text-align:justify;">Now let us see their solution in detail.Please go over <strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/" target="_blank">interview question</a></strong> again before continuing reading following comments.</p>
<p style="text-align:justify;"><strong>Solution by</strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44580" target="_blank"><strong>Zod </strong><br />
</a></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">DECLARE </span><span style="color:#434343;">@Class1 </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:#434343;">@Class2 </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:#434343;">@Class3 </span><span style="color:blue;">INT</span><span style="color:gray;">,<br />
</span><span style="color:#434343;">@Class1Total </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:#434343;">@Class2Total </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:#434343;">@Class3Total </span><span style="color:blue;">INT<br />
SET </span><span style="color:#434343;">@Class1Total </span><span style="color:blue;">= </span><span style="color:black;">0<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@Class2Total </span><span style="color:blue;">= </span><span style="color:black;">0<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@Class3Total </span><span style="color:blue;">= </span><span style="color:black;">0<br />
</span><span style="color:blue;">DECLARE </span><span style="color:black;">student_CURSOR </span><span style="color:blue;">CURSOR FOR<br />
SELECT </span><span style="color:black;">Class1</span><span style="color:gray;">, </span><span style="color:black;">Class2</span><span style="color:gray;">, </span><span style="color:black;">Class3<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll<br />
</span><span style="color:blue;">OPEN </span><span style="color:black;">student_CURSOR<br />
</span><span style="color:blue;">FETCH </span><span style="color:black;">next </span><span style="color:blue;">FROM </span><span style="color:black;">student_CURSOR<br />
</span><span style="color:blue;">INTO </span><span style="color:#434343;">@Class1</span><span style="color:gray;">, </span><span style="color:#434343;">@Class2</span><span style="color:gray;">, </span><span style="color:#434343;">@Class3<br />
</span><span style="color:blue;">WHILE </span><span style="color:#434343;">@@FETCH_STATUS </span><span style="color:blue;">= </span><span style="color:black;">0<br />
</span><span style="color:blue;">BEGIN<br />
SET </span><span style="color:#434343;">@Class1Total </span><span style="color:blue;">= </span><span style="color:#434343;">@Class1Total </span><span style="color:gray;">+ </span><span style="color:#434343;">@Class1<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@Class2Total </span><span style="color:blue;">= </span><span style="color:#434343;">@Class2Total </span><span style="color:gray;">+ </span><span style="color:#434343;">@Class2<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@Class3Total </span><span style="color:blue;">= </span><span style="color:#434343;">@Class3Total </span><span style="color:gray;">+ </span><span style="color:#434343;">@Class3<br />
</span><span style="color:blue;">FETCH </span><span style="color:black;">next </span><span style="color:blue;">FROM </span><span style="color:black;">student_CURSOR<br />
</span><span style="color:blue;">INTO </span><span style="color:#434343;">@Class1</span><span style="color:gray;">, </span><span style="color:#434343;">@Class2</span><span style="color:gray;">, </span><span style="color:#434343;">@Class3<br />
</span><span style="color:blue;">END<br />
CLOSE </span><span style="color:black;">student_CURSOR<br />
</span><span style="color:blue;">DEALLOCATE </span><span style="color:black;">student_CURSOR<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Class1 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:#434343;">@Class1Total </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) + </span><span style="color:red;">' students'<br />
</span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Class2 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:#434343;">@Class2Total </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) + </span><span style="color:red;">' students'<br />
</span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Class3 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:#434343;">@Class3Total </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) + </span><span style="color:red;">' students'<br />
</span><span style="color:black;">GO<br />
</span></code>
</p>
<p style="text-align:justify;"><strong>Solution by </strong><strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44584" target="_blank">Eric</a></strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT<br />
</span><span style="color:red;">'Class1 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:black;">[Class1] </span><span style="color:blue;">AS INT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) + </span><span style="color:red;">' students.\n'<br />
</span><span style="color:gray;">+ </span><span style="color:red;">'Class2 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:black;">[Class2] </span><span style="color:blue;">AS INT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) + </span><span style="color:red;">' students.\n'<br />
</span><span style="color:gray;">+ </span><span style="color:red;">'Class3 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:black;">[Class3] </span><span style="color:blue;">AS INT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) + </span><span style="color:red;">' students.\n'<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">[StudentsEnroll]</span><span style="color:gray;">;</span></code>
</p>
<p style="text-align:justify;"><strong>Solution by </strong><strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44598" target="_blank">Imran Mohammed</a></strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">CLASS</span><span style="color:gray;">+ </span><span style="color:red;">' has '</span><span style="color:gray;">+</span><span style="color:magenta;">CONVERT(</span><span>VARCHAR</span><span>(</span><span>10</span><span style="color:gray;">),</span><span style="color:magenta;">COUNT</span><span style="color:gray;">(</span><span style="color:black;">orders </span><span style="color:gray;">))+</span><span style="color:red;">' Students ' 'Output' </span><span style="color:blue;">FROM </span><span style="color:gray;">(<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">students</span><span style="color:gray;">, </span><span style="color:black;">Class</span><span style="color:gray;">, </span><span style="color:black;">Orders<br />
</span><span style="color:blue;">FROM<br />
</span><span style="color:gray;">(</span><span style="color:blue;">SELECT </span><span style="color:black;">students</span><span style="color:gray;">, </span><span style="color:black;">class1</span><span style="color:gray;">, </span><span style="color:black;">class2</span><span style="color:gray;">,</span><span style="color:black;">class3<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">studentsenroll </span><span style="color:gray;">) </span><span style="color:black;">p<br />
UNPIVOT<br />
</span><span style="color:gray;">(</span><span style="color:black;">Orders </span><span style="color:blue;">FOR </span><span style="color:black;">Class </span><span style="color:blue;">IN<br />
</span><span style="color:gray;">(</span><span style="color:black;">class1</span><span style="color:gray;">, </span><span style="color:black;">class2</span><span style="color:gray;">, </span><span style="color:black;">class3 </span><span style="color:gray;">)<br />
)</span><span style="color:blue;">AS </span><span style="color:black;">unpvt</span><span style="color:gray;">) </span><span style="color:black;">X </span><span style="color:blue;">WHERE </span><span style="color:black;">orders </span><span style="color:blue;">= </span><span style="color:black;">1 </span><span style="color:blue;">GROUP BY </span><span style="color:black;">class</span></code>
</p>
<p style="text-align:justify;"><strong>Solution by </strong><strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44605" target="_blank">bhadeliaimran</a></strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">DECLARE </span><span style="color:#434343;">@opXml </span><span style="color:blue;">AS </span><span style="color:black;">XML<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@opXml </span><span style="color:blue;">= </span><span style="color:red;">'&lt;ClassStud value=''' </span><span style="color:gray;">+ </span><span style="color:magenta;">REPLACE</span><span style="color:gray;">(<br />
(</span><span style="color:blue;">SELECT<br />
</span><span style="color:red;">'Class1 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:black;">Class1 </span><span style="color:blue;">AS </span><span style="color:black;">SMALLINT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">4</span><span style="color:gray;">)) + </span><span style="color:red;">' students' </span><span style="color:gray;">,<br />
</span><span style="color:red;">',Class2 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:black;">Class2 </span><span style="color:blue;">AS </span><span style="color:black;">SMALLINT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">4</span><span style="color:gray;">)) + </span><span style="color:red;">' students' </span><span style="color:gray;">,<br />
</span><span style="color:red;">',Class3 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:black;">Class3 </span><span style="color:blue;">AS </span><span style="color:black;">SMALLINT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">4</span><span style="color:gray;">)) + </span><span style="color:red;">' students'<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">[StudentsEnroll]<br />
</span><span style="color:blue;">FOR </span><span style="color:black;">XML PATH</span><span style="color:gray;">(</span><span style="color:red;">''</span><span style="color:gray;">) ), </span><span style="color:red;">','</span><span style="color:gray;">, </span><span style="color:red;">''' /&gt;&lt;ClassStud value='''</span><span style="color:gray;">) + </span><span style="color:red;">''' /&gt;'<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">x.value</span><span style="color:gray;">(</span><span style="color:red;">'@value'</span><span style="color:gray;">, </span><span style="color:red;">'varchar(100)'</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">[output]<br />
</span><span style="color:blue;">FROM </span><span style="color:#434343;">@opXml</span><span style="color:black;">.nodes</span><span style="color:gray;">(</span><span style="color:red;">'/ClassStud'</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">p</span><span style="color:gray;">(</span><span style="color:black;">x</span><span style="color:gray;">)</span></code>
</p>
<p style="text-align:justify;"><strong>Solution by </strong><strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44607" target="_blank">fly</a></strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">DECLARE </span><span style="color:#434343;">@tbl </span><span style="color:blue;">TABLE </span><span style="color:gray;">(</span><span style="color:black;">i </span><span style="color:blue;">INT</span><span style="color:gray;">)<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:#434343;">@tbl </span><span style="color:gray;">(</span><span style="color:black;">i</span><span style="color:gray;">)<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">1<br />
</span><span style="color:blue;">UNION<br />
SELECT </span><span style="color:black;">2<br />
</span><span style="color:blue;">UNION<br />
SELECT </span><span style="color:black;">3<br />
</span><span style="color:blue;">SELECT<br />
</span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:black;">i </span><span style="color:blue;">= </span><span style="color:black;">1 </span><span style="color:blue;">THEN </span><span style="color:red;">'Class 1 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST </span><span style="color:gray;">(</span><span style="color:black;">class1 </span><span style="color:blue;">AS INT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">)) + </span><span style="color:red;">' Students' </span><span style="color:blue;">ELSE<br />
</span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:black;">i </span><span style="color:blue;">= </span><span style="color:black;">2 </span><span style="color:blue;">THEN </span><span style="color:red;">'Class 2 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST </span><span style="color:gray;">(</span><span style="color:black;">class2 </span><span style="color:blue;">AS INT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">)) + </span><span style="color:red;">' Students' </span><span style="color:blue;">ELSE<br />
</span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:black;">i </span><span style="color:blue;">= </span><span style="color:black;">3 </span><span style="color:blue;">THEN </span><span style="color:red;">'Class 3 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">SUM</span><span style="color:gray;">(</span><span style="color:magenta;">CAST </span><span style="color:gray;">(</span><span style="color:black;">class3 </span><span style="color:blue;">AS INT</span><span style="color:gray;">)) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">)) + </span><span style="color:red;">' Students' </span><span style="color:blue;">ELSE </span><span style="color:red;">'' </span><span style="color:blue;">END<br />
END<br />
END<br />
FROM </span><span style="color:black;">[StudentsEnroll]<br />
</span><span style="color:blue;">JOIN </span><span style="color:#434343;">@tbl </span><span style="color:black;">t </span><span style="color:blue;">ON </span><span style="color:black;">i </span><span style="color:gray;">&lt;= </span><span style="color:black;">3<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">i</span></code>
</p>
<p style="text-align:justify;"><strong>Solution by<a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comment-44629" target="_blank"> pom</a></strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:red;">'class1 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">((</span><span style="color:blue;">SELECT </span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll </span><span style="color:blue;">WHERE </span><span style="color:black;">class1</span><span style="color:blue;">=</span><span style="color:black;">1 </span><span style="color:blue;">GROUP BY </span><span style="color:black;">class1</span><span style="color:gray;">) </span><span style="color:blue;">AS CHAR</span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">)) + </span><span style="color:red;">'Students'<br />
</span><span style="color:blue;">UNION<br />
SELECT </span><span style="color:red;">'class2 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">((</span><span style="color:blue;">SELECT </span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll </span><span style="color:blue;">WHERE </span><span style="color:black;">class2</span><span style="color:blue;">=</span><span style="color:black;">1 </span><span style="color:blue;">GROUP BY </span><span style="color:black;">class2</span><span style="color:gray;">) </span><span style="color:blue;">AS CHAR</span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">)) + </span><span style="color:red;">'Students'<br />
</span><span style="color:blue;">UNION<br />
SELECT </span><span style="color:red;">'class3 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">((</span><span style="color:blue;">SELECT </span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll </span><span style="color:blue;">WHERE </span><span style="color:black;">class3</span><span style="color:blue;">=</span><span style="color:black;">1 </span><span style="color:blue;">GROUP BY </span><span style="color:black;">class3</span><span style="color:gray;">) </span><span style="color:blue;">AS CHAR</span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">)) + </span><span style="color:red;">'Students'</span></code>
</p>
<p style="text-align:justify;">Other two solution proposed earlier in<a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/" target="_blank"> original article</a>.</p>
<p style="text-align:justify;"><strong>Solution 1 &#8211; Using only SELECT statement</strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">DECLARE </span><span style="color:#434343;">@Col </span><span style="color:blue;">INT<br />
SET </span><span style="color:#434343;">@Col </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">WHILE </span><span style="color:gray;">(</span><span style="color:#434343;">@Col </span><span style="color:gray;">&lt; </span><span style="color:black;">4</span><span style="color:gray;">)<br />
</span><span style="color:blue;">BEGIN<br />
EXEC</span><span style="color:gray;">(</span><span style="color:red;">‘SELECT     ”Class’</span><span style="color:gray;">+</span><span style="color:#434343;">@Col</span><span style="color:gray;">+</span><span style="color:red;">‘ Has ” + CAST(COUNT(Students) AS VARCHAR(100)) + ” Students” Results<br />
FROM         studentsenroll<br />
WHERE         Class’</span><span style="color:gray;">+</span><span style="color:#434343;">@Col</span><span style="color:gray;">+</span><span style="color:red;">‘ = 1<br />
GROUP BY      Class’</span><span style="color:gray;">+</span><span style="color:#434343;">@Col</span><span style="color:gray;">)<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@Col </span><span style="color:blue;">= </span><span style="color:#434343;">@Col </span><span style="color:gray;">+ </span><span style="color:black;">1<br />
</span><span style="color:blue;">CONTINUE<br />
END</span></code>
</p>
<p style="text-align:justify;"><strong>Solution 2 &#8211; Getting results in one resultset</strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:red;">‘Class1 has ’ </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) +</span><span style="color:red;">‘ Students’<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">Class1 </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">Class1<br />
</span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">‘Class2 has ’ </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) +</span><span style="color:red;">‘ Students’<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">Class2 </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">Class2<br />
</span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">‘Class3 has ’ </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) +</span><span style="color:red;">‘ Students’<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">Class3 </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">Class3</span></code>
</p>
<p style="text-align:justify;"><span style="color:black;">Now the real question is which of this articles are favorite solution of yours. Please leave your choice along with reason in comment. </span></p>
<p style="text-align:justify;"><span style="color:black;">I promise if you can not write solution but if you understand the proposed solution in this article you will usually pass any database T-SQL problem in interviews. Additionally, if you are looking for job in SQL Server related area please find your <strong><a href="http://jobs.sqlauthority.com/" target="_blank">right job</a> </strong>here. Make sure to read all the <strong><a href="http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/" target="_blank">interview questions and answers for SQL Server 2008</a></strong> before you appear for interview. </span></p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Best Practices, Pinal Dave, Readers Contribution, Software Development, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Puzzle, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1754/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1754/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1754/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1754&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/12/17/sql-server-interesting-interview-questions-revisited/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; Interesting Interview Questions &#8211; Part 2 &#8211; Puzzle &#8211; Solution</title>
		<link>http://blog.sqlauthority.com/2008/12/11/sql-server-interesting-interview-questions-part-2-puzzle-solution/</link>
		<comments>http://blog.sqlauthority.com/2008/12/11/sql-server-interesting-interview-questions-part-2-puzzle-solution/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 01:30:57 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Puzzle]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1652</guid>
		<description><![CDATA[Yesterday we looked at Puzzle and I did got great response to this question. Very interestingly not many got it right. First go through the puzzle first and then come back here and read answer.
Read Original Interview Question and Puzzle.
Question: Select all the person from table PersonColor who have same color as ColorCode or have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1652&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Yesterday we looked at Puzzle and I did got great response to this question. Very interestingly not many got it right. First go through the puzzle first and then come back here and read answer.</p>
<h3 style="text-align:justify;"><strong><a href="http://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/" target="_blank">Read Original Interview Question and Puzzle</a></strong>.</h3>
<p style="text-align:justify;"><em><strong>Question: Select all the person from table PersonColor who have same color as ColorCode or have more colors than table ColorCode.</strong></em></p>
<p style="text-align:justify;"><em>UPDATE: Following solution is written with assumption that in SelectedColors table Name and ColorCode are Primary Key. This requirement was not specified in original question.<strong><br />
</strong></em></p>
<p><code style="font-size:12px;"><span style="color:green;">/*Answer to Interview Question*/<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">Name<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">PersonColors pc<br />
</span><span style="color:blue;">INNER JOIN </span><span style="color:black;">SelectedColors sc </span><span style="color:blue;">ON </span><span style="color:black;">sc.ColorCode </span><span style="color:blue;">= </span><span style="color:black;">pc.ColorCode<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">pc.Name<br />
</span><span style="color:blue;">HAVING </span><span style="color:magenta;">COUNT</span><span style="color:gray;">(</span><span style="color:black;">pc.ColorCode</span><span style="color:gray;">) &gt;= (</span><span style="color:blue;">SELECT </span><span style="color:magenta;">COUNT</span><span style="color:gray;">(</span><span style="color:black;">ColorCode</span><span style="color:gray;">) </span><span style="color:blue;">FROM </span><span style="color:black;">SelectedColors</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO</span></code>
</p>
<p style="text-align:justify;"><img class="alignnone" src="http://www.pinaldave.com/bimg/int2.gif" alt="" width="159" height="98" /></p>
<p style="text-align:justify;">If you want to download complete script for this interview question. <a href="http://www.pinaldave.com/bimg/interviewquestion.zip">Please download it from here</a>.</p>
<p style="text-align:justify;">Complete script of the puzzle is also listed here.</p>
<p><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks<br />
GO<br />
</span><span style="color:green;">/*Create First Table PersonColors*/<br />
</span><span style="color:blue;">CREATE TABLE </span><span style="color:black;">PersonColors </span><span style="color:gray;">(</span><span style="color:black;">Name </span><span style="color:blue;">VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">), </span><span style="color:black;">ColorCode </span><span style="color:blue;">VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">))<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">PersonColors </span><span style="color:gray;">(</span><span style="color:black;">Name</span><span style="color:gray;">,</span><span style="color:black;">ColorCode</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Blue'</span><span style="color:gray;">),(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Green'</span><span style="color:gray;">),(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Brown'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'Mike'</span><span style="color:gray;">,</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Mike'</span><span style="color:gray;">,</span><span style="color:red;">'Blue'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'James'</span><span style="color:gray;">,</span><span style="color:red;">'Green'</span><span style="color:gray;">),(</span><span style="color:red;">'James'</span><span style="color:gray;">,</span><span style="color:red;">'Brown'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'Joe'</span><span style="color:gray;">,</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Joe'</span><span style="color:gray;">,</span><span style="color:red;">'Blue'</span><span style="color:gray;">),(</span><span style="color:red;">'Joe'</span><span style="color:gray;">,</span><span style="color:red;">'Green'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'Matt'</span><span style="color:gray;">,</span><span style="color:red;">'Brown'</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">SELECT </span><span style="color:gray;">*<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">PersonColors<br />
GO<br />
</span><span style="color:green;">/*Create Second Table SelectedColors*/<br />
</span><span style="color:blue;">CREATE TABLE </span><span style="color:black;">SelectedColors </span><span style="color:gray;">(</span><span style="color:black;">ColorCode </span><span style="color:blue;">VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">))<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">SelectedColors </span><span style="color:gray;">(</span><span style="color:black;">ColorCode</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Blue'</span><span style="color:gray;">),(</span><span style="color:red;">'Green'</span><span style="color:gray;">)<br />
</span><span style="color:blue;">SELECT </span><span style="color:gray;">*<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">SelectedColors<br />
GO<br />
</span><span style="color:green;">/*Answer to Interview Question*/<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">Name<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">PersonColors pc<br />
</span><span style="color:blue;">INNER JOIN </span><span style="color:black;">SelectedColors sc </span><span style="color:blue;">ON </span><span style="color:black;">sc.ColorCode </span><span style="color:blue;">= </span><span style="color:black;">pc.ColorCode<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">pc.Name<br />
</span><span style="color:blue;">HAVING </span><span style="color:magenta;">COUNT</span><span style="color:gray;">(</span><span style="color:black;">pc.ColorCode</span><span style="color:gray;">) &gt;= (</span><span style="color:blue;">SELECT </span><span style="color:magenta;">COUNT</span><span style="color:gray;">(</span><span style="color:black;">ColorCode</span><span style="color:gray;">) </span><span style="color:blue;">FROM </span><span style="color:black;">SelectedColors</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO<br />
</span><span style="color:gray;">*</span><span style="color:black;">Clean up </span><span style="color:blue;">DATABASE</span><span style="color:green;">*/<br />
</span><span style="color:blue;">DROP TABLE </span><span style="color:black;">PersonColors<br />
</span><span style="color:blue;">DROP TABLE </span><span style="color:black;">SelectedColors<br />
GO</span></code></p>
<p style="text-align:justify;">Let me know your opinion about this puzzle.</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Best Practices, Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Puzzle, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1652/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1652/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1652/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1652&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/12/11/sql-server-interesting-interview-questions-part-2-puzzle-solution/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/int2.gif" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Interesting Interview Questions &#8211; Part 2 &#8211; Puzzle</title>
		<link>http://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/</link>
		<comments>http://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 01:30:35 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Puzzle]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1640</guid>
		<description><![CDATA[In the recent time of recession my company is able to continue its progress and we are hiring. It is very surprising to me that many developers who have experience with SQL Server could not get following simple question right. There were nearly 40 candidates I interviewed but none of the candidate was able to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1640&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">In the recent time of recession my company is able to continue its progress and we are hiring. It is very surprising to me that many developers who have experience with SQL Server could not get following simple question right. There were nearly 40 candidates I interviewed but none of the candidate was able to solve this problem. When I displayed final answer they could not believe that it is that simple.</p>
<p style="text-align:justify;">When I asked some of the MCITP or Oracle certified candidate about why they can not get this simple question, they smiled and answered that I did not have that on my blog or on my <strong><a href="http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/" target="_blank">interview questions list</a></strong>. Let us go over the interview question.</p>
<p style="text-align:justify;">Let us create two tables. Once Created SELECT values from both the tables.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks<br />
GO<br />
</span><span style="color:green;">/*Create First Table PersonColors*/<br />
</span><span style="color:blue;">CREATE TABLE </span><span style="color:black;">PersonColors </span><span style="color:gray;">(</span><span style="color:black;">Name </span><span style="color:blue;">VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">), </span><span style="color:black;">ColorCode </span><span style="color:blue;">VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">))<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">PersonColors </span><span style="color:gray;">(</span><span style="color:black;">Name</span><span style="color:gray;">,</span><span style="color:black;">ColorCode</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Blue'</span><span style="color:gray;">),(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Green'</span><span style="color:gray;">),(</span><span style="color:red;">'Tom'</span><span style="color:gray;">,</span><span style="color:red;">'Brown'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'Mike'</span><span style="color:gray;">,</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Mike'</span><span style="color:gray;">,</span><span style="color:red;">'Blue'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'James'</span><span style="color:gray;">,</span><span style="color:red;">'Green'</span><span style="color:gray;">),(</span><span style="color:red;">'James'</span><span style="color:gray;">,</span><span style="color:red;">'Brown'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'Joe'</span><span style="color:gray;">,</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Joe'</span><span style="color:gray;">,</span><span style="color:red;">'Blue'</span><span style="color:gray;">),(</span><span style="color:red;">'Joe'</span><span style="color:gray;">,</span><span style="color:red;">'Green'</span><span style="color:gray;">),<br />
(</span><span style="color:red;">'Matt'</span><span style="color:gray;">,</span><span style="color:red;">'Brown'</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">SELECT </span><span style="color:gray;">*<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">PersonColors<br />
GO<br />
</span><span style="color:green;">/*Create Second Table SelectedColors*/<br />
</span><span style="color:blue;">CREATE TABLE </span><span style="color:black;">SelectedColors </span><span style="color:gray;">(</span><span style="color:black;">ColorCode </span><span style="color:blue;">VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">100</span><span style="color:gray;">))<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">SelectedColors </span><span style="color:gray;">(</span><span style="color:black;">ColorCode</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">'Red'</span><span style="color:gray;">),(</span><span style="color:red;">'Blue'</span><span style="color:gray;">),(</span><span style="color:red;">'Green'</span><span style="color:gray;">)<br />
</span><span style="color:blue;">SELECT </span><span style="color:gray;">*<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">SelectedColors<br />
GO </span></code>
</p>
<p style="text-align:justify;">The resultset of created table is as following.</p>
<p style="text-align:justify;"><img class="alignnone" src="http://www.pinaldave.com/bimg/int1.gif" alt="" width="230" height="474" /></p>
<p style="text-align:justify;">Now the question is find all the persons from table PersonColor who have all the ColorCode mentioned in the table ColorCode. From the example it is clear that final result will contain Tom and Joe as answer. Tom has Red, Blue and Green as well Brown colorcode. If any person have Red, Blue and Green color they should qualify in our resultset. Joe has all the same colorcode as ColorCode table so it should also qualify in our resultset. Other person Mike and James did not have same kind of colorcode as table ColorCode.</p>
<p style="text-align:justify;"><em><strong>In summary, Select all the person from table PersonColor who have same color as ColorCode or have more colors than table ColorCode.</strong></em></p>
<p style="text-align:justify;">When you look at this question it is very simple and answer is very simple as well. One of my employee was able to solve it in 3 mins. However, all the 40 interview candidates found it very difficult to write the query for the same.</p>
<p style="text-align:justify;">Now before looking at the answer, please try to find the solution by yourself. Once you find the solution compare to the solution I have and see if you got it correct.</p>
<p style="text-align:justify;">Expected Resultset should look like this.</p>
<p style="text-align:justify;"><img class="alignnone" src="http://www.pinaldave.com/bimg/int2.gif" alt="" width="159" height="98" /></p>
<p style="text-align:justify;">Again, it may look very simple I would strongly suggest you try to solve it by yourself. If you can not solve it then try to look solution here.</p>
<p style="text-align:justify;"><strong>UPDATE:</strong> I have used SQL Server 2008 script to generate the same table. I thank <strong>Tejas Shah</strong> for providing the script of SQL Server 2005 <strong><a href="http://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/#comment-44674">here</a></strong>.</p>
<p style="text-align:justify;"><strong><a href="http://blog.sqlauthority.com/2008/12/11/sql-server-interesting-interview-questions-part-2-puzzle-solution/" target="_blank">Click here for Solution. (Go live on 12/11/2008)<br />
</a></strong>
</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Puzzle, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1640/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1640&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/12/10/sql-server-interesting-interview-questions-part-2-puzzle/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/int1.gif" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/int2.gif" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Find Table Rowcount Without Using T-SQL and Without Opening Table</title>
		<link>http://blog.sqlauthority.com/2008/12/09/sql-server-find-table-rowcount-without-using-t-sql-and-without-opening-table/</link>
		<comments>http://blog.sqlauthority.com/2008/12/09/sql-server-find-table-rowcount-without-using-t-sql-and-without-opening-table/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 01:30:57 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Add-On]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Documentation]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Management Studio]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[SQL Storage]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1635</guid>
		<description><![CDATA[Recently I have been busy with interviewing many candidates for my organization. We are looking for some smart and experienced developers for some senior positions. I have wrote this previously SQL SERVER &#8211; Interesting Interview Questions.
I had asked following question to one of the candidate and he was not able to answer this question. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1635&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Recently I have been busy with interviewing many candidates for my organization. We are looking for some smart and experienced developers for some senior positions. I have wrote this previously <strong><a href="http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/" target="_blank">SQL SERVER &#8211; Interesting Interview Questions</a></strong>.</p>
<p style="text-align:justify;">I had asked following question to one of the candidate and he was not able to answer this question. I promised him that I will put answer to this question on blog.</p>
<p style="text-align:justify;">The question was : <strong>How to find table rowcount without using T-SQL and without opening table?</strong></p>
<p style="text-align:justify;">Answer : Well it is quite simple by using SQL Server Management Studio.</p>
<p style="text-align:justify;">Right click on table and click on Properties. Now on left nav of opened window click on storage and under general section there is display of Row Count.</p>
<p style="text-align:justify;"><img class="alignnone" src="http://www.pinaldave.com/bimg/rcnt.gif" alt="" width="500" height="449" /></p>
<p style="text-align:justify;">If you have similar interesting questions, please share with me. I will post on blog.</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Pinal Dave, SQL, SQL Add-On, SQL Authority, SQL Documentation, SQL Interview Questions and Answers, SQL Query, SQL Server, SQL Server Management Studio, SQL Tips and Tricks, T SQL, Technology Tagged: Howto, SQL Storage <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1635/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1635/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1635/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1635/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1635/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1635/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1635/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1635/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1635/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1635/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1635&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/12/09/sql-server-find-table-rowcount-without-using-t-sql-and-without-opening-table/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/rcnt.gif" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Interesting Interview Questions</title>
		<link>http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/</link>
		<comments>http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 01:30:53 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1624</guid>
		<description><![CDATA[Today at my organization we had nearly 30 interviews scheduled of DBA and .NET developers. I really enjoyed participating in interviewing panel. It was really fun to ask questions and learn so many new things from developers. I will share few of my experience with candidates here.
Those who are scheduled for interview with me next [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1624&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Today at my organization we had nearly 30 interviews scheduled of DBA and .NET developers. I really enjoyed participating in interviewing panel. It was really fun to ask questions and learn so many new things from developers. I will share few of my experience with candidates here.</p>
<p style="text-align:justify;">Those who are scheduled for interview with me next week this is one question I will be sure asking you besides questions from my<a href="http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/" target="_blank"> interview questions and answer series</a>.</p>
<p style="text-align:justify;"><strong><em>Question: If we have following table, please write script to display output below.</em></strong></p>
<table style="text-align:justify;" border="0" cellspacing="0" cellpadding="0" width="289">
<col width="97"></col>
<col span="3" width="64"></col>
<tbody>
<tr>
<td width="97" height="17"><strong> TableName: </strong></td>
<td colspan="2" width="128"><strong> StudentsEnroll </strong></td>
<td width="64"></td>
</tr>
<tr>
<td height="17"></td>
</tr>
<tr>
<td height="17"><strong> Students </strong></td>
<td style="border-left:medium none;"><strong> Class1 </strong></td>
<td style="border-left:medium none;"><strong> Class2 </strong></td>
<td style="border-left:medium none;"><strong> Class3 </strong></td>
</tr>
<tr>
<td height="17">Student1</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
<td style="border-top:medium none;border-left:medium none;" align="right">0</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
</tr>
<tr>
<td height="17">Student2</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
</tr>
<tr>
<td height="17">Student3</td>
<td style="border-top:medium none;border-left:medium none;" align="right">0</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
<td style="border-top:medium none;border-left:medium none;" align="right">0</td>
</tr>
<tr>
<td height="17">Student4</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
<td style="border-top:medium none;border-left:medium none;" align="right">0</td>
<td style="border-top:medium none;border-left:medium none;" align="right">1</td>
</tr>
</tbody>
</table>
<p style="text-align:justify;"><strong>Output:</strong></p>
<table style="text-align:justify;" border="0" cellspacing="0" cellpadding="0" width="161">
<col width="97"></col>
<col width="64"></col>
<tbody>
<tr>
<td colspan="2" width="161" height="17">Class1 has 3 Students</td>
</tr>
<tr>
<td colspan="2" height="17">Class2 has 2 Students</td>
</tr>
<tr>
<td colspan="2" height="17">Class3 has 3 Students</td>
</tr>
</tbody>
</table>
<p style="text-align:justify;"><strong>Solution:</strong></p>
<p style="text-align:justify;">Create same data -</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE DATABASE<br />
</span><span style="color:black;">GO</span></code></p>
<p style="text-align:justify;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">[StudentsEnroll] </span><span style="color:gray;">(<br />
</span><span style="color:black;">[Students] [varchar] </span><span style="color:gray;">(</span><span style="color:black;">50</span><span style="color:gray;">) </span><span style="color:blue;">CONSTRAINT </span><span style="color:black;">[DF_StudentsEnroll_Students] </span><span style="color:blue;">DEFAULT </span><span style="color:gray;">(</span><span style="color:red;">&#8221;</span><span style="color:gray;">),<br />
</span><span style="color:black;">[Class1] [bit] </span><span style="color:gray;">NOT NULL </span><span style="color:blue;">CONSTRAINT </span><span style="color:black;">[DF_StudentsEnroll_Class1] </span><span style="color:blue;">DEFAULT </span><span style="color:gray;">(</span><span style="color:black;">0</span><span style="color:gray;">),<br />
</span><span style="color:black;">[Class2] [bit] </span><span style="color:gray;">NOT NULL </span><span style="color:blue;">CONSTRAINT </span><span style="color:black;">[DF_StudentsEnroll_Class2] </span><span style="color:blue;">DEFAULT </span><span style="color:gray;">(</span><span style="color:black;">0</span><span style="color:gray;">),<br />
</span><span style="color:black;">[Class3] [bit] </span><span style="color:gray;">NOT NULL </span><span style="color:blue;">CONSTRAINT </span><span style="color:black;">[DF_StudentsEnroll_Class3] </span><span style="color:blue;">DEFAULT </span><span style="color:gray;">(</span><span style="color:black;">0</span><span style="color:gray;">)<br />
) </span><span style="color:blue;">ON </span><span style="color:black;">[PRIMARY]<br />
GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">StudentsEnroll </span><span style="color:gray;">(</span><span style="color:black;">Students</span><span style="color:gray;">, </span><span style="color:black;">Class1</span><span style="color:gray;">, </span><span style="color:black;">Class2</span><span style="color:gray;">, </span><span style="color:black;">Class3</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">&#8216;Student1&#8242;</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">0</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">StudentsEnroll </span><span style="color:gray;">(</span><span style="color:black;">Students</span><span style="color:gray;">, </span><span style="color:black;">Class1</span><span style="color:gray;">, </span><span style="color:black;">Class2</span><span style="color:gray;">, </span><span style="color:black;">Class3</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">&#8216;Student2&#8242;</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">StudentsEnroll </span><span style="color:gray;">(</span><span style="color:black;">Students</span><span style="color:gray;">, </span><span style="color:black;">Class1</span><span style="color:gray;">, </span><span style="color:black;">Class2</span><span style="color:gray;">, </span><span style="color:black;">Class3</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">&#8216;Student3&#8242;</span><span style="color:gray;">, </span><span style="color:black;">0</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">0</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">StudentsEnroll </span><span style="color:gray;">(</span><span style="color:black;">Students</span><span style="color:gray;">, </span><span style="color:black;">Class1</span><span style="color:gray;">, </span><span style="color:black;">Class2</span><span style="color:gray;">, </span><span style="color:black;">Class3</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:red;">&#8216;Student4&#8242;</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">0</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">)<br />
</span><span style="color:black;">GO</span>
</p>
<p style="text-align:justify;"><strong>Solution 1 &#8211; Using only SELECT statement</strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">DECLARE </span><span style="color:#434343;">@Col </span><span style="color:blue;">INT<br />
SET </span><span style="color:#434343;">@Col </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">WHILE </span><span style="color:gray;">(</span><span style="color:#434343;">@Col </span><span style="color:gray;">&lt; </span><span style="color:black;">4</span><span style="color:gray;">)<br />
</span><span style="color:blue;">BEGIN<br />
EXEC</span><span style="color:gray;">(</span><span style="color:red;">'SELECT     ''Class'</span><span style="color:gray;">+</span><span style="color:#434343;">@Col</span><span style="color:gray;">+</span><span style="color:red;">' Has '' + CAST(COUNT(Students) AS VARCHAR(100)) + '' Students'' Results<br />
FROM         studentsenroll<br />
WHERE         Class'</span><span style="color:gray;">+</span><span style="color:#434343;">@Col</span><span style="color:gray;">+</span><span style="color:red;">' = 1<br />
GROUP BY      Class'</span><span style="color:gray;">+</span><span style="color:#434343;">@Col</span><span style="color:gray;">)<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@Col </span><span style="color:blue;">= </span><span style="color:#434343;">@Col </span><span style="color:gray;">+ </span><span style="color:black;">1<br />
</span><span style="color:blue;">CONTINUE<br />
END</span></code>
</p>
<p style="text-align:justify;"><strong>Solution 2 &#8211; Getting results in one resultset</strong></p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:red;">'Class1 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) +</span><span style="color:red;">' Students'<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">Class1 </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">Class1<br />
</span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Class2 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) +</span><span style="color:red;">' Students'<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">Class2 </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">Class2<br />
</span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Class3 has ' </span><span style="color:gray;">+ </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:magenta;">COUNT</span><span style="color:gray;">(*) </span><span style="color:blue;">AS VARCHAR</span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">)) +</span><span style="color:red;">' Students'<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">StudentsEnroll<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">Class3 </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">Class3</span></code>
</p>
<p style="text-align:justify;">If you know any other method or script to achieve the same result, please share here with your friends.</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Database, Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1624/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1624/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1624/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1624&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/12/07/sql-server-interesting-interview-questions/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; Roadmap of Microsoft Certifications &#8211; SQL Server Certifications</title>
		<link>http://blog.sqlauthority.com/2008/12/01/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications/</link>
		<comments>http://blog.sqlauthority.com/2008/12/01/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 01:30:46 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Documentation]]></category>
		<category><![CDATA[SQL Download]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Performance]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQLAuthority News]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Microsoft Certifications]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1597</guid>
		<description><![CDATA[In these times of economical slowdown, more and more IT professionals are concerned about their jobs and their qualifications. It is a common trend for developers to start looking for ways to update their skills when jobs are not secure. Pure knowledge and real world work experience are always a good way to help secure [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1597&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">In these times of economical slowdown, more and more IT professionals are concerned about their jobs and their qualifications. It is a common trend for developers to start looking for ways to update their skills when jobs are not secure. Pure knowledge and real world work experience are always a good way to help secure your future. One way to demonstrate knowledge is by having a certification in the technology one claims to be expert in.</p>
<p style="text-align:justify;">Microsoft offers a series of certifications for IT professional and developers. In this article we will cover the following topics.</p>
<ol style="text-align:justify;">
<li>Importance of Certificates</li>
<li>Certification Structure</li>
<li>SQL Server Certifications</li>
<li>Exam Preparation</li>
<li>Registration for Exam</li>
<li>Post Examination Benefits</li>
</ol>
<p style="text-align:justify;">Microsoft certifications are very reputed and validate developers’ hands-on experience.</p>
<h3 style="text-align:justify;"><a href="http://dotnetslackers.com/articles/sql/Roadmap-of-Microsoft-Certifications-SQL-Server-Certifications.aspx" target="_blank">Click here to read complete article.</a></h3>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Database, DBA, SQL, SQL Authority, SQL Documentation, SQL Download, SQL Interview Questions and Answers, SQL Performance, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology Tagged: Microsoft Certifications <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1597/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1597/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1597/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1597&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/12/01/sql-server-roadmap-of-microsoft-certifications-sql-server-certifications/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; Simulate INNER JOIN using LEFT JOIN statement &#8211; Performance Analysis</title>
		<link>http://blog.sqlauthority.com/2008/10/25/sql-server-simulate-inner-join-using-left-join-statement-performance-analysis/</link>
		<comments>http://blog.sqlauthority.com/2008/10/25/sql-server-simulate-inner-join-using-left-join-statement-performance-analysis/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 01:30:15 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Joins]]></category>
		<category><![CDATA[SQL Performance]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1426</guid>
		<description><![CDATA[Just a day ago, while I was working with JOINs I find one interesting observation, which has prompted me to create following example. Before we continue further let me make very clear that INNER JOIN should be used where it can not be used and simulating INNER JOIN using any other JOINs will degrade the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1426&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Just a day ago, while I was working with JOINs I find one interesting observation, which has prompted me to create following example. Before we continue further let me make very clear that <em><strong>INNER JOIN should be used where it can not be used and simulating INNER JOIN using any other JOINs will degrade the performance</strong></em>. If there are scopes to convert any OUTER JOIN to INNER JOIN it should be done with priority.</p>
<p style="text-align:justify;">Run following two script and observe the resultset. Resultset will be identical.</p>
<p><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks<br />
GO<br />
</span><span style="color:green;">/* Example of INNER JOIN */<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">p.ProductID</span><span style="color:gray;">, </span><span style="color:black;">piy.ProductID<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">Production.Product p<br />
</span><span style="color:blue;">INNER JOIN </span><span style="color:black;">Production.ProductInventory piy </span><span style="color:blue;">ON </span><span style="color:black;">piy.ProductID </span><span style="color:blue;">= </span><span style="color:black;">p.ProductID<br />
GO<br />
</span><span style="color:green;">/* Example of LEFT JOIN simulating INNER JOIN */<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">p.ProductID</span><span style="color:gray;">, </span><span style="color:black;">piy.ProductID<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">Production.Product p<br />
</span><span style="color:magenta;">LEFT </span><span style="color:blue;">JOIN </span><span style="color:black;">Production.ProductInventory piy </span><span style="color:blue;">ON </span><span style="color:black;">1 </span><span style="color:blue;">= </span><span style="color:black;">1<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">piy.ProductID </span><span style="color:blue;">= </span><span style="color:black;">p.ProductID<br />
GO </span></code></p>
<p style="text-align:justify;">After looking at identical result the first thing came in to my mind was what is the behind the scene plan. When looking at the actual execution plan of the query it is very clear that even LEFT JOIN is used SQL Server Query Optimizer converts it to INNER JOIN as it determined that there is no need of OUTER LEFT JOIN and INNER JOIN will give better performance.</p>
<p style="text-align:justify;"><img class="alignnone" src="http://www.pinaldave.com/bimg/leftinner.gif" alt="" width="500" height="608" /></p>
<p style="text-align:justify;">Looking at above scenario it makes us think how smart Query Optimizer Engine is and how it might be saving lots of performance related issue for sub-optimal queries.</p>
<p style="text-align:justify;">Now let us understand why LEFT JOIN acts as  INNER JOIN. When 1= 1 is used in ON clause it is always true and converts LEFT JOIN to CROSS JOIN. However, when WHERE condition&#8217;s effect is applied to above CROSS JOIN it produces the result similar to INNER JOIN in our case. SQL Server Query Optimizer interprets this earlier and uses INNER JOIN right away.</p>
<p style="text-align:justify;">I think this is good interview questions to ask. Interview question which can be asked is <strong>&#8220;How to write OUTER JOIN which will give you exact same result, execution plan and performance as INNER JOIN?&#8221;</strong></p>
<p style="text-align:justify;">If there is any other explanation or if you know if there is any similar example please let me know and I will post on this blog.</p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Pinal Dave, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Joins, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1426/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1426/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1426/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1426/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1426/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1426/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1426/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1426/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1426/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1426/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1426&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/10/25/sql-server-simulate-inner-join-using-left-join-statement-performance-analysis/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/leftinner.gif" medium="image" />
	</item>
		<item>
		<title>SQLAuthority News &#8211; TOP Downloads &#8211; Bookmark</title>
		<link>http://blog.sqlauthority.com/2008/10/24/sqlauthority-news-top-downloads-bookmark/</link>
		<comments>http://blog.sqlauthority.com/2008/10/24/sqlauthority-news-top-downloads-bookmark/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 01:30:02 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Download]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQLAuthority News]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Outsourcing Technology]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1424</guid>
		<description><![CDATA[Recently I have got many many request for SQL Server Interview Questions and Answers as well related articles. It seems many people are looking for Job or appearing for interview at this time of the year. I have included list of the my top downloads in side bar of the blog, still I receive many [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1424&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Recently I have got many many request for SQL Server Interview Questions and Answers as well related articles. It seems many people are looking for Job or appearing for interview at this time of the year. I have included list of the my top downloads in side bar of the blog, still I receive many curious questions as side bar does not show up in RSS feed.</p>
<p style="text-align:justify;">Please book mark this post for future reference.</p>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-2008-Download-Interview-Questions-and-Answers" target="_blank">SQL Server 2008 Interview Questions and Answers Download</a></h3>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=Data-Warehousing-Business-Intelligence-Interview-Questions-and-Answers-Download" target="_blank">SQL Server Data Warehousing and BI Interview Q and A Download</a></h3>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-Database-Coding-Standards-and-Guidelines-Complete-List-Download" target="_blank">SQL Server Database Coding Standards and Guidelines Complete List Download</a></h3>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-Cheat-Sheet" target="_blank">SQL Server Cheat Sheet Download</a></h3>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-Download-Frequently-Asked-Generic-Interview-Questions" target="_blank">SQL Server Frequently Asked Generic Interview Questions Download</a></h3>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-Download-SQL-Server-Management-Studio-Keyboard-Shortcuts-(SSMS-Shortcuts)" target="_blank">SQL Server Management Studio Keyboard Shortcuts (SSMS Shortcuts) Download</a></h3>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-2008-Brochure-Download" target="_blank">SQL Server 2008 Brochure Download</a></h3>
<h3 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-ScreenSaver-Download" target="_blank">SQL Server 2008 Screen Saver Download</a></h3>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Best Practices, Database, Software Development, SQL, SQL Authority, SQL Download, SQL Interview Questions and Answers, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology Tagged: Outsourcing Technology <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1424/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1424&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/10/24/sqlauthority-news-top-downloads-bookmark/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server &#8211; 2008 &#8211; Cheat Sheet &#8211; One Page PDF Download</title>
		<link>http://blog.sqlauthority.com/2008/10/02/sql-server-2008-cheat-sheet-one-page-pdf-download/</link>
		<comments>http://blog.sqlauthority.com/2008/10/02/sql-server-2008-cheat-sheet-one-page-pdf-download/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 01:30:48 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Add-On]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Coding Standards]]></category>
		<category><![CDATA[SQL Documentation]]></category>
		<category><![CDATA[SQL Download]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[SQL Cheat Sheet]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1289</guid>
		<description><![CDATA[Very frequently I have been asked to create a page, post or article where in one page all the important concepts of SQL Server are covered. SQL Server 2008 is very large subject and can not be even covered 1000 of pages. In daily life of DBA there are few commands very frequently used and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1289&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;">Very frequently I have been asked to create a page, post or article where in one page all the important concepts of SQL Server are covered. SQL Server 2008 is very large subject and can not be even covered 1000 of pages. In daily life of DBA there are few commands very frequently used and for novice developers it is good to keep all the important SQL Script and SQL Statements handy.</p>
<p style="text-align:justify;">I have attempted to create cheat sheet for SQL Server 2008 most important commands. User can print this in one A4 size page and keep along with them. This can be used in interviews where T-SQL scripts are being asked.</p>
<p style="text-align:justify;">Let me know your opinion and if you find this useful.</p>
<h2 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-Cheat-Sheet" target="_blank">Download SQL Server 2008 Cheat Sheet</a></h2>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Best Practices, Database, DBA, Pinal Dave, Software Development, SQL, SQL Add-On, SQL Authority, SQL Coding Standards, SQL Documentation, SQL Download, SQL Interview Questions and Answers, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQL Utility, T SQL, Technology Tagged: SQL Cheat Sheet <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1289&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/10/02/sql-server-2008-cheat-sheet-one-page-pdf-download/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Complete List Download</title>
		<link>http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/</link>
		<comments>http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 01:30:39 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Constraint and Keys]]></category>
		<category><![CDATA[SQL Cursor]]></category>
		<category><![CDATA[SQL Data Storage]]></category>
		<category><![CDATA[SQL DateTime]]></category>
		<category><![CDATA[SQL Documentation]]></category>
		<category><![CDATA[SQL Download]]></category>
		<category><![CDATA[SQL Error Messages]]></category>
		<category><![CDATA[SQL Function]]></category>
		<category><![CDATA[SQL Index]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Joins]]></category>
		<category><![CDATA[SQL Performance]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Security]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBCC]]></category>
		<category><![CDATA[SQL Stored Procedure]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Trigger]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[SQLAuthority]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[SQL XML]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1134</guid>
		<description><![CDATA[Download SQL Server 2008 Interview Questions and Answers Complete List
Interview is very important event for any person. A good interview leads to good career if candidate is willing to learn. I always enjoy interview questions and answers series. This is my very humble attempt to write SQL Server 2008 interview questions and answers. SQL Server [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1134&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-2008-Download-Interview-Questions-and-Answers"><strong>Download SQL Server 2008 Interview Questions and Answers Complete List</strong></a></h2>
<p style="text-align:justify;">Interview is very important event for any person. A good interview leads to good career if candidate is willing to learn. I always enjoy interview questions and answers series. This is my very humble attempt to write SQL Server 2008 interview questions and answers. SQL Server is very large subject and not everything is usually asked in interview. In interview what matters the most is <strong>conceptual knowledge</strong> and <strong>learning attitude</strong>.</p>
<p style="text-align:justify;">I have listed all the series in this post so that it can be easily downloaded and used. All the questions are collected and listed in one PDF which is here to download. If you have any question or if you want to add to any of the question please send me mail or write a comment.</p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/12/sql-server-2008-interview-questions-and-answers-part-1/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 1</strong></a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/13/sql-server-2008-interview-questions-and-answers-part-2/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 2</strong></a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/14/sql-server-2008-interview-questions-and-answers-part-3/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 3</strong></a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/15/sql-server-2008-interview-questions-and-answers-part-4/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 4</strong></a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/16/sql-server-2008-interview-questions-and-answers-part-5/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 5</strong></a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/17/sql-server-2008-interview-questions-and-answers-part-6/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 6</strong></a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/18/sql-server-2008-interview-questions-and-answers-part-7/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 7</strong></a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2008/09/19/sql-server-2008-interview-questions-and-answers-part-8/"><strong>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 8</strong></a></p>
<h2 style="text-align:justify;"><a href="http://www.pinaldave.com/best-sql-server-download.cfm?download=SQL-SERVER-2008-Download-Interview-Questions-and-Answers"><strong>Download SQL Server 2008 Interview Questions and Answers Complete List</strong></a></h2>
<p style="text-align:justify;">
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Database, Pinal Dave, SQL, SQL Authority, SQL Constraint and Keys, SQL Cursor, SQL Data Storage, SQL DateTime, SQL Documentation, SQL Download, SQL Error Messages, SQL Function, SQL Index, SQL Interview Questions and Answers, SQL Joins, SQL Performance, SQL Query, SQL Scripts, SQL Security, SQL Server, SQL Server DBCC, SQL Stored Procedure, SQL Tips and Tricks, SQL Trigger, SQL Utility, SQLAuthority, T SQL, Technology Tagged: SQL XML <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1134&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 8</title>
		<link>http://blog.sqlauthority.com/2008/09/19/sql-server-2008-interview-questions-and-answers-part-8/</link>
		<comments>http://blog.sqlauthority.com/2008/09/19/sql-server-2008-interview-questions-and-answers-part-8/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 01:30:07 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Data Warehousing]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Data Storage]]></category>
		<category><![CDATA[SQL Function]]></category>
		<category><![CDATA[SQL Index]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server DBCC]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[SQLAuthority]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1012</guid>
		<description><![CDATA[SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Complete List Download
What is Data Compression?
In SQL SERVE 2008 Data Compression comes in two flavors:

 Row Compression
 Page Compression

Row Compression
Row compression changes the format of physical storage of data. It minimize the metadata (column information, length, offsets etc) associated with each record. Numeric data types and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1012&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2 style="text-align:justify;"><strong><a href="http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/" target="_blank">SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Complete List Download</a></strong></h2>
<p style="text-align:justify;"><strong>What is Data Compression?</strong></p>
<p style="text-align:justify;">In SQL SERVE 2008 Data Compression comes in two flavors:<strong></strong></p>
<ul class="unIndentedList" style="text-align:justify;">
<li> Row Compression</li>
<li> Page Compression</li>
</ul>
<p style="text-align:justify;"><strong>Row Compression</strong></p>
<p style="text-align:justify;">Row compression changes the format of physical storage of data. It minimize the metadata (column information, length, offsets etc) associated with each record. Numeric data types and fixed length strings are stored in variable-length storage format, just like Varchar.  (<a href="http://blog.sqlauthority.com/2008/07/06/sql-server-2008-introduction-to-row-compression/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>Page Compression</strong></p>
<p style="text-align:justify;">Page compression allows common data to be shared between rows for a given page. Its uses the following techniques to compress data:<strong></strong></p>
<ul class="unIndentedList" style="text-align:justify;">
<li> Row compression.</li>
<li> Prefix Compression. For every column in a page duplicate prefixes are identified. These prefixes are saved in compression information headers (CI) which resides after page header. A reference number is assigned to these prefixes and that reference number is replaced where ever those prefixes are being used.</li>
</ul>
<p style="text-align:justify;"><strong>Dictionary Compression</strong>.</p>
<p style="text-align:justify;">Dictionary compression searches for duplicate values throughout the page and stores them in CI. The main difference between prefix and dictionary compression is that prefix is only restricted to one column while dictionary is applicable to the complete page.</p>
<p style="text-align:justify;"><strong>What is use of DBCC Commands?</strong></p>
<p style="text-align:justify;">The Transact-SQL programming language provides DBCC statements that act as Database Console Commands for SQL Server.  DBCC commands are used to perform following tasks.</p>
<ul class="unIndentedList" style="text-align:justify;">
<li> Maintenance tasks on database, index, or filegroup.</li>
<li> Tasks that gather and display various types of information.</li>
<li> Validation operations on a database, table, index, catalog, filegroup, or allocation of database pages.</li>
<li> Miscellaneous tasks such as enabling trace flags or removing a DLL from memory.</li>
</ul>
<p style="text-align:justify;">(<a href="http://blog.sqlauthority.com/2007/05/15/sql-server-dbcc-commands-list-documented-and-undocumented/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>How to find tables without Indexes?</strong></p>
<p style="text-align:justify;">Run following query in Query Editor.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:gray;">&lt;</span><span style="color:black;">database_name</span><span style="color:gray;">&gt;;<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">SCHEMA_NAME</span><span style="color:gray;">(</span><span style="color:black;">schema_id</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">schema_name<br />
</span><span style="color:gray;">,</span><span style="color:black;">name </span><span style="color:blue;">AS </span><span style="color:black;">table_name<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">sys.tables<br />
</span><span style="color:blue;">WHERE </span><span style="color:magenta;">OBJECTPROPERTY</span><span style="color:gray;">(</span><span style="color:magenta;">OBJECT_ID</span><span style="color:gray;">,</span><span style="color:red;">'IsIndexed'</span><span style="color:gray;">) </span><span style="color:blue;">= </span><span style="color:black;">0<br />
</span><span style="color:blue;">ORDER BY </span><span style="color:black;">schema_name</span><span style="color:gray;">, </span><span style="color:black;">table_name</span><span style="color:gray;">;<br />
</span><span style="color:black;">GO</span></code>
</p>
<p style="text-align:justify;"><strong>How to copy the tables, schema and views from one SQL Server to another?</strong></p>
<p style="text-align:justify;">There are multiple ways to do this.</p>
<ol style="text-align:justify;">
<li> &#8220;Detach Database&#8221; from one server and &#8220;Attach Database&#8221; to another server.</li>
<li> Manually script all the objects using SSMS and run the script on new server.</li>
<li> Use Wizard of SSMS. (<a href="http://blog.sqlauthority.com/2007/08/21/sql-server-2005-create-script-to-copy-database-schema-and-all-the-objects-stored-procedure-functions-triggers-tables-views-constraints-and-all-other-database-objects/" target="_blank">Read More Here</a>)</li>
</ol>
<p style="text-align:justify;"><strong>How to copy data from one table to another table?</strong></p>
<p style="text-align:justify;">There are multiple ways to do this.</p>
<p style="text-align:justify;"><strong><em>1) </em></strong><strong><em>INSERT INTO SELECT</em></strong></p>
<p style="text-align:justify;">This method is used when table is already created in the database earlier and data is to be inserted into this table from another table. If columns listed in insert clause and select clause are same, they are not required to list them.</p>
<p style="text-align:justify;"><strong><em>2) SELECT INTO</em></strong></p>
<p style="text-align:justify;">This method is used when table is not created earlier and needs to be created when data from one table is to be inserted into newly created table from another table. New table is created with same data types as selected columns.</p>
<p style="text-align:justify;">(<a href="http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What is Catalog Views?</strong></p>
<p style="text-align:justify;">Catalog views return information that is used by the SQL Server Database Engine. Catalog Views are the most general interface to the catalog metadata and provide the most efficient way to obtain, transform, and present customized forms of this information. All user-available catalog metadata is exposed through catalog views.</p>
<p style="text-align:justify;"><strong>What is PIVOT and UNPIVOT?</strong></p>
<p style="text-align:justify;"><em>A Pivot Table</em> can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table.</p>
<p style="text-align:justify;">UNPIVOT table is reverse of PIVOT Table. (<a href="http://blog.sqlauthority.com/2008/05/29/sql-server-unpivot-table-example/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What is Filestream?</strong></p>
<p style="text-align:justify;">Filestream allows you to store large objects in the file system and have these files integrated within the database. It enables SQL Server based applications to store unstructured data such as documents, images, audios, videos etc. in the file system. FILESTREAM basically integrates the SQL Server Database Engine with New Technology File System (NTFS); it basically stores the data in varbinary (max) data type. Using this data type, the unstructured data is stored in the NTFS file system and the SQL Server Database Engine manages the link between the Filestream column and the actual file located in the NTFS. Using Transact SQL statements users can insert, update, delete and select the data stored in FILESTREAM enabled tables.</p>
<p style="text-align:justify;"><strong>What is Dirty Read ?</strong></p>
<p style="text-align:justify;">A dirty read occurs when two operations say, read and write occurs together giving the incorrect or unedited data. Suppose, A has changed a row, but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong so that is Dirty Read.<strong> </strong></p>
<p style="text-align:justify;"><strong>What is SQLCMD?</strong></p>
<p style="text-align:justify;">sqlcmd is enhanced version of the isql and osql and it provides way more functionality than other two options. In other words sqlcmd is better replacement of isql (which will be deprecated eventually) and osql (not included in SQL Server 2005 RTM). sqlcmd can work two modes &#8211; i) BATCH and ii) interactive modes. (<a href="http://blog.sqlauthority.com/2007/09/06/sql-server-2005-introduction-and-explanation-to-sqlcmd/" target="_blank">Read More</a>)</p>
<p style="text-align:justify;"><strong>What is Aggregate Functions? </strong></p>
<p style="text-align:justify;">Aggregate functions perform a calculation on a set of values and return a single value. Aggregate functions ignore NULL values except COUNT function. HAVING clause is used, along with GROUP BY, for filtering query using aggregate values.</p>
<p style="text-align:justify;">Following functions are aggregate functions.</p>
<p style="text-align:justify;"><strong>AVG, MIN, CHECKSUM_AGG, SUM, COUNT, STDEV, COUNT_BIG, STDEVP, GROUPING, VAR, MAX, VARP </strong>(<a href="http://blog.sqlauthority.com/2008/01/19/sql-server-introduction-to-aggregate-functions/" target="_blank">Read More Here</a> )</p>
<p style="text-align:justify;"><strong>What do you mean by Table Sample?<br />
</strong>TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set. (<a href="http://blog.sqlauthority.com/2007/05/27/sql-server-2005-limiting-result-sets-by-using-tablesample-examples/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What is Row_Number()?<br />
</strong>ROW_NUMBER() returns a column as an expression that contains the row&#8217;s number within the result set. This is only a number used in the context of the result set, if the result changes, the ROW_NUMBER() will change.
</p>
<p style="text-align:justify;"><strong>What are Ranking Functions?</strong></p>
<p style="text-align:justify;">Ranking functions return a ranking value for each row in a partition. All the ranking functions are non-deterministic. Different Ranking functions are:</p>
<p style="text-align:justify;"><strong><em>ROW_NUMBER () OVER ([&lt;partition_by_clause&gt;] &lt;order_by_clause&gt;)</em></strong><br />
Returns the sequential number of a row within a partition of a result set, starting at 1 for the first row in each partition.</p>
<p style="text-align:justify;"><strong><em>RANK () OVER ([&lt;partition_by_clause&gt;] &lt;order_by_clause&gt;)</em></strong><br />
Returns the rank of each row within the partition of a result set.</p>
<p style="text-align:justify;"><strong><em>DENSE_RANK () OVER ([&lt;partition_by_clause&gt;] &lt;order_by_clause&gt;)</em></strong><br />
Returns the rank of rows within the partition of a result set, without any gaps in the ranking. (<a href="http://blog.sqlauthority.com/2007/10/09/sql-server-2005-sample-example-of-ranking-functions-row_number-rank-dense_rank-ntile/" target="_blank">Read More Here</a> )
</p>
<p style="text-align:justify;"><strong>What is the difference between UNION and UNION ALL?</strong></p>
<p style="text-align:justify;"><strong><em>UNION</em></strong><em><br />
</em>The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.<strong></strong></p>
<p style="text-align:justify;"><strong><em>UNION ALL</em></strong><em><br />
</em>The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.
</p>
<p style="text-align:justify;">The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table. (<a href="http://blog.sqlauthority.com/2007/03/10/sql-server-union-vs-union-all-which-is-better-for-performance/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What is B-Tree?</strong></p>
<p style="text-align:justify;">The database server uses a B-tree structure to organize index information. B-Tree generally has following types of index pages or nodes:</p>
<ul class="unIndentedList" style="text-align:justify;">
<li> <em>root node:</em> A root node contains node pointers to branch nodes which can be only one.</li>
<li> <em>branch nodes:</em> A branch node contains pointers to leaf nodes or other branch nodes which can be two or more.</li>
<li> <em>leaf nodes</em>: A leaf node contains index items and horizontal pointers to other leaf nodes which can be many.</li>
</ul>
<p style="text-align:justify;">© Copyright 2000-2009<a title="Pinal Dave" href="http://www.pinaldave.com/" target="_blank"> Pinal Dave.</a> All Rights Reserved. <a href="http://blog.sqlauthority.com/" target="_blank">SQLAuthority.com</a></p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
Posted in Data Warehousing, Database, Pinal Dave, SQL, SQL Authority, SQL Data Storage, SQL Function, SQL Index, SQL Interview Questions and Answers, SQL Query, SQL Scripts, SQL Server, SQL Server DBCC, SQL Tips and Tricks, SQL Utility, SQLAuthority, T SQL, Technology  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1012/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1012/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1012/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1012/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1012/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1012/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1012/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1012/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1012/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1012/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1012&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/09/19/sql-server-2008-interview-questions-and-answers-part-8/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 7</title>
		<link>http://blog.sqlauthority.com/2008/09/18/sql-server-2008-interview-questions-and-answers-part-7/</link>
		<comments>http://blog.sqlauthority.com/2008/09/18/sql-server-2008-interview-questions-and-answers-part-7/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 01:30:19 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Error Messages]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Security]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[SQLAuthority]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1010</guid>
		<description><![CDATA[SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Complete List Download
How can we rewrite sub-queries into simple select statements or with joins?
Yes we can write using Common Table Expression (CTE). A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1010&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2 style="text-align:justify;"><strong><a href="http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/" target="_blank">SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Complete List Download</a></strong></h2>
<p style="text-align:justify;"><strong>How can </strong><strong>we</strong><strong> rewrite sub-queries into simple select statements or with joins?</strong></p>
<p style="text-align:justify;">Yes we can write using Common Table Expression (CTE). A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query.</p>
<p style="text-align:justify;">E.g.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks<br />
GO<br />
</span><span style="color:blue;">WITH </span><span style="color:black;">EmployeeDepartment_CTE </span><span style="color:blue;">AS </span><span style="color:gray;">(<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">EmployeeID</span><span style="color:gray;">,</span><span style="color:black;">DepartmentID</span><span style="color:gray;">,</span><span style="color:black;">ShiftID<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">HumanResources.EmployeeDepartmentHistory<br />
</span><span style="color:gray;">)<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">ecte.EmployeeId</span><span style="color:gray;">,</span><span style="color:black;">ed.DepartmentID</span><span style="color:gray;">, </span><span style="color:black;">ed.Name</span><span style="color:gray;">,</span><span style="color:black;">ecte.ShiftID<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">HumanResources.Department ed<br />
</span><span style="color:blue;">INNER JOIN </span><span style="color:black;">EmployeeDepartment_CTE ecte </span><span style="color:blue;">ON </span><span style="color:black;">ecte.DepartmentID </span><span style="color:blue;">= </span><span style="color:black;">ed.DepartmentID<br />
GO</span></code>
</p>
<p style="text-align:justify;"><strong>What is CLR?</strong></p>
<p style="text-align:justify;">In SQL Server 2008, SQL Server objects such as user-defined functions can be created using such CLR languages. This CLR language support extends not only to user-defined functions, but also to stored procedures and triggers. You can develop such CLR add-ons to SQL Server using Visual Studio 2008.<strong> </strong>(<a href="http://blog.sqlauthority.com/2008/03/14/sql-server-2005-introduction-to-clr-and-integration-to-clr-with-sql-simple-sample-example-of-clr/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What are synonyms?</strong></p>
<p style="text-align:justify;">Synonyms give you the ability to provide alternate names for database objects. You can alias object names; for example, using the Employee table as Emp. You can also shorten names. This is especially useful when dealing with three and four part names; for example, shortening server.database.owner.object to object. (<a href="http://blog.sqlauthority.com/2008/01/07/sql-server-2005-introduction-and-explanation-to-synonym-helpful-t-sql-feature-for-developer/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What is LINQ?</strong></p>
<p style="text-align:justify;">Language Integrated Query (LINQ) adds the ability to query objects using .NET languages. The LINQ to SQL object/relational mapping (O/RM) framework provides the following basic features:</p>
<ul class="unIndentedList" style="text-align:justify;">
<li> Tools to create classes (usually called <em>entities</em>) mapped to database tables</li>
<li> Compatibility with LINQ&#8217;s standard query operations</li>
<li> The DataContext class, with features such as entity record monitoring, automatic SQL statement generation, record concurrency detection, and much more</li>
</ul>
<p style="text-align:justify;"><strong>What is Isolation Levels?</strong></p>
<p style="text-align:justify;">Transactions specify an isolation level that defines the degree to which one transaction must be isolated from resource or data modifications made by other transactions. Isolation levels are described in terms of which concurrency side-effects, such as dirty reads or phantom reads, are allowed.</p>
<p style="text-align:justify;">Transaction isolation levels control:</p>
<ul class="unIndentedList" style="text-align:justify;">
<li> Whether locks are taken when data is read, and what type of locks are requested.</li>
<li> How long the read locks are held.</li>
<li> Whether a read operation referencing rows modified by another transaction:</li>
<li> Blocks until the exclusive lock on the row is freed.</li>
<li> Retrieves the committed version of the row that existed at the time the statement or transaction started.</li>
<li> Reads the uncommitted data modification. (<a href="http://blog.sqlauthority.com/2008/08/18/sql-server-detailed-explanation-of-transaction-lock-lock-type-avoid-locks/" target="_blank">Read More Here</a>)</li>
</ul>
<p style="text-align:justify;"><strong>What is use of EXCEPT Clause?</strong></p>
<p style="text-align:justify;"><strong>EXCEPT clause is similar to MINUS operation in Oracle</strong><strong>.</strong> The EXCEPT query and MINUS query returns all rows in the first query that are not returned in the second query. Each SQL statement within the EXCEPT query and MINUS query must have the same number of fields in the result sets with similar data types. (<a href="http://blog.sqlauthority.com/2008/08/07/sql-server-except-clause-in-sql-server-is-similar-to-minus-clause-in-oracle/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What is XPath?</strong></p>
<p style="text-align:justify;">XPath uses a set of expressions to select nodes to be processed. The most common expression that you&#8217;ll use is the location path expression, which returns back a set of nodes called a <em>node set</em>. XPath can use both an unabbreviated and an abbreviated syntax. The following is the unabbreviated syntax for a location path:</p>
<p style="text-align:justify;">/axisName::nodeTest[predicate]/axisName::nodeTest[predicate]<strong></strong></p>
<p style="text-align:justify;"><strong>What is NOLOCK?</strong></p>
<p style="text-align:justify;">Using the NOLOCK query optimizer hint is generally considered good practice in order to improve concurrency on a busy system. When the NOLOCK hint is included in a SELECT statement, no locks are taken when data is read. The result is a Dirty Read, which means that another process could be updating the data at the exact time you are reading it. There are no guarantees that your query will retrieve the most recent data. The advantage to performance is that your reading of data will not block updates from taking place, and updates will not block your reading of data. SELECT statements take Shared (Read) locks. This means that multiple SELECT statements are allowed simultaneous access, but other processes are blocked from modifying the data. The updates will queue until all the reads have completed, and reads requested after the update will wait for the updates to complete. The result to your system is delay (blocking). (<a href="http://blog.sqlauthority.com/2007/04/27/sql-server-2005-locking-hints-and-examples/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>How would you handle error in SQL SERVER 2008?</strong></p>
<p style="text-align:justify;">SQL Server now supports the use of TRY&#8230;CATCH constructs for providing rich error handling. TRY&#8230;CATCH lets us build error handling at the level we need, in the way we need to, by setting a region where if any error occurs, it will break out of the region and head to an error handler. The basic structure is as follows:</p>
<p style="text-align:justify;">BEGIN TRY</p>
<p style="text-align:justify;">&lt;<em>code</em>&gt;</p>
<p style="text-align:justify;">END TRY</p>
<p style="text-align:justify;">BEGIN CATCH</p>
<p style="text-align:justify;">&lt;<em>code</em>&gt;</p>
<p style="text-align:justify;">END CATCH</p>
<p style="text-align:justify;">So if any error occurs in the TRY block, execution is diverted to the CATCH block, and the error can be dealt.</p>
<p style="text-align:justify;"><strong>What is RAISEERROR?</strong></p>
<p style="text-align:justify;">RaiseError generates an error message and initiates error processing for the session. RAISERROR can either reference a user-defined message stored in the <strong>sys.messages</strong> catalog view or build a message dynamically. The message is returned as a server error message to the calling application or to an associated CATCH block of a TRY&#8230;CATCH construct. (<a href="http://blog.sqlauthority.com/2007/10/03/sql-server-2005-explanation-of-try%E2%80%A6catch-and-error-handling-with-raiseerror-function/" target="_blank">Read More Here</a>)<strong></strong></p>
<p style="text-align:justify;"><strong>How to rebuild Master Databse?</strong></p>
<p style="text-align:justify;">Master database is system database and it contains information about running server&#8217;s configuration. When SQL Server 2005 is installed it usually creates master, model, msdb, tempdb resource and distribution system database by default. Only Master database is the one which is absolutely must have database. Without Master database SQL Server cannot be started. This is the reason it is extremely important to backup Master database.</p>
<p style="text-align:justify;">To rebuild the Master database, Run Setup.exe, verify, and repair a SQL Server instance, and rebuild the system databases. This procedure is most often used to rebuild the <strong>master</strong> database for a corrupted installation of SQL Server.</p>
<p style="text-align:justify;"><strong>What is XML Datatype?</strong></p>
<p style="text-align:justify;">The <strong>xml</strong> data type lets you store XML documents and fragments in a SQL Server database. An XML fragment is an XML instance that is missing a single top-level element. You can create columns and variables of the <strong>xml</strong> type and store XML instances in them. The <strong>xml</strong> data type and associated methods help integrate XML into the relational framework of SQL Server.</p>
<p style="text-align:justify;">© Copyright 2000-2009<a title="Pinal Dave" href="http://www.pinaldave.com/" target="_blank"> Pinal Dave.</a> All Rights Reserved. <a href="http://blog.sqlauthority.com/" target="_blank">SQLAuthority.com</a></p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlauthority.wordpress.com/1010/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlauthority.wordpress.com/1010/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1010/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1010/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1010/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1010/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1010/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1010/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1010/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1010/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1010/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1010/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1010&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/09/18/sql-server-2008-interview-questions-and-answers-part-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers &#8211; Part 6</title>
		<link>http://blog.sqlauthority.com/2008/09/17/sql-server-2008-interview-questions-and-answers-part-6/</link>
		<comments>http://blog.sqlauthority.com/2008/09/17/sql-server-2008-interview-questions-and-answers-part-6/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 01:30:05 +0000</pubDate>
		<dc:creator>pinaldave</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Data Storage]]></category>
		<category><![CDATA[SQL DateTime]]></category>
		<category><![CDATA[SQL Function]]></category>
		<category><![CDATA[SQL Index]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[SQLAuthority]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1008</guid>
		<description><![CDATA[SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Complete List Download
3) Questions of SQL SERVER 2008
What are the basic functions for master, msdb, model, tempdb and resource databases?
The master database holds information for all databases located on the SQL Server instance and is theglue that holds the engine together. Because SQL Server cannot start [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1008&subd=sqlauthority&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2 style="text-align:justify;"><strong><a href="http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/" target="_blank">SQL SERVER &#8211; 2008 &#8211; Interview Questions and Answers Complete List Download</a></strong></h2>
<p style="text-align:justify;"><strong>3) </strong><strong>Questions of SQL SERVER 2008</strong></p>
<p style="text-align:justify;"><strong>What are the basic functions for master, msdb, model, tempdb and resource databases?</strong></p>
<p style="text-align:justify;"><em>The <strong>master</strong> database </em>holds information for all databases located on the SQL Server instance and is theglue that holds the engine together. Because SQL Server cannot start without a functioning masterdatabase, you must administer this database with care.</p>
<p style="text-align:justify;"><em>The <strong>msdb</strong> database </em>stores information regarding database backups, SQL Agent information, DTS packages, SQL Server jobs, and some replication information such as for log shipping.</p>
<p style="text-align:justify;"><em>The <strong>tempdb</strong> </em>holds temporary objects such as global and local temporary tables and stored procedures.</p>
<p style="text-align:justify;"><em>The <strong>model</strong></em> is essentially a template database used in the creation of any new user database created in the instance.</p>
<p style="text-align:justify;"><em>The <strong>resoure</strong> Database </em>is a read-only database that contains all the system objects that are included with SQL Server. SQL Server system objects, such as sys.objects, are physically persisted in the Resource database, but they logically appear in the sys schema of every database. The Resource database does not contain user data or user metadata.</p>
<p style="text-align:justify;"><strong>What is Service Broker?</strong></p>
<p style="text-align:justify;">Service Broker is a message-queuing technology in SQL Server that allows developers to integrate SQL Server fully into distributed applications. Service Broker is feature which provides facility to SQL Server to send an asynchronous, transactional message. it allows a database to send a message to another database without waiting for the response, so the application will continue to function if the remote database is temporarily unavailable. (<a href="http://blog.sqlauthority.com/2008/07/18/sql-server-introduction-to-service-broker/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>Where SQL server user names and passwords are stored in SQL server?</strong></p>
<p style="text-align:justify;">They get stored in System Catalog Views sys.server_principals and sys.sql_logins.</p>
<p style="text-align:justify;"><strong>What is Policy Management?</strong></p>
<p style="text-align:justify;">Policy Management in SQL SERVER 2008 allows you to define and enforce policies for configuring and managing SQL Server across the enterprise. Policy-Based Management is configured in SQL Server Management Studio (SSMS).  Navigate to the Object Explorer and expand the Management node and the Policy Management node; you will see the Policies, Conditions, and Facets nodes. (<a href="http://blog.sqlauthority.com/2008/06/13/sql-server-2008-introduction-to-policy-management-enforcing-rules-on-sql-server/" target="_blank">Read More Here</a>)<strong></strong></p>
<p style="text-align:justify;"><strong>What is Replication and Database Mirroring?</strong></p>
<p style="text-align:justify;">Database mirroring can be used with replication to provide availability for the publication database. Database mirroring involves two copies of a single database that typically reside on different computers. At any given time, only one copy of the database is currently available to clients which are known as the principal database. Updates made by clients to the principal database are applied on the other copy of the database, known as the mirror database. Mirroring involves applying the transaction log from every insertion, update, or deletion made on the principal database onto the mirror database.</p>
<p style="text-align:justify;"><strong>What are Sparse Columns?</strong></p>
<p style="text-align:justify;">A sparse column<em> </em>is another tool used to reduce the amount of physical storage used in a database. They are the ordinary columns that have an optimized storage for null values. Sparse columns reduce the space requirements for null values at the cost of more overhead to retrieve nonnull values. (<a href="http://blog.sqlauthority.com/2008/07/10/sql-server-2008-introduction-to-sparse-columns/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What does TOP Operator Do?</strong></p>
<p style="text-align:justify;">The TOP operator is used to specify the number of rows to be returned by a query. The TOP operator has new addition in SQL SERVER 2008 that it accepts variables as well as literal values and can be used with INSERT, UPDATE, and DELETES statements.</p>
<p style="text-align:justify;"><strong>What is CTE?</strong></p>
<p style="text-align:justify;">CTE is an abbreviation Common Table Expression. A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement<strong>. </strong>A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. (<a href="http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/" target="_blank">Read More Here</a>)</p>
<p style="text-align:justify;"><strong>What is MERGE Statement?</strong><strong><br />
</strong>MERGE is a new feature that provides an efficient way to perform multiple DML operations. In previous versions of SQL Server, we had to write separate statements to INSERT, UPDATE, or DELETE data based on certain conditions, but now, using MERGE statement we can include the logic of such data modifications in one statement that even checks when the data is matched then just update it and when unmatched then insert it. One of the most important advantages of MERGE statement is all the data is read and processed only once.  (<a href="http://blog.sqlauthority.com/2008/08/28/sql-server-2008-introduction-to-merge-statement-one-statement-for-insert-update-delete/" target="_blank">Read More Here</a>)
</p>
<p style="text-align:justify;"><strong>What is Filtered Index?</strong></p>
<p style="text-align:justify;">Filtered Index is used to index a portion of rows in a table that means it applies filter on INDEX which improves query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes. When we see an Index created with some where clause then that is actually a FILTERED INDEX.</p>
<p style="text-align:justify;"><strong>Which are new data types introduced in SQL SERVER 2008?</strong></p>
<p style="text-align:justify;"><strong><em>The GEOMETRY Type: </em></strong>The GEOMETRY data type is a system .NET common language runtime (CLR) data type in SQL Server. This type represents data in a two-dimensional Euclidean coordinate system.</p>
<p style="text-align:justify;"><strong><em>The GEOGRAPHY Type:</em></strong> The GEOGRAPHY datatype&#8217;s functions are the same as with GEOMETRY. The difference between the two is that when you specify GEOGRAPHY, you are usually specifying points in terms of latitude and longitude.</p>
<p style="text-align:justify;"><strong><em>New Date and Time Datatypes:</em></strong> SQL Server 2008 introduces four new datatypes related to date and time: DATE, TIME, DATETIMEOFFSET, and DATETIME2.</p>
<ul class="unIndentedList" style="text-align:justify;">
<li> <strong><em>DATE</em></strong><em>:</em> The new DATE type just stores the date itself. It is based on the Gregorian calendar and handles years from 1 to 9999.</li>
<li> <strong><em>TIME</em></strong><em>:</em> The new TIME (<em>n</em>) type stores time with a range of 00:00:00.0000000 through 23:59:59.9999999. The precision is allowed with this type. TIME supports seconds down to 100 nanoseconds. The <em>n </em>in TIME (<em>n</em>) defines this level of fractional second precision, from 0 to 7 digits of precision.</li>
</ul>
<ul class="unIndentedList" style="text-align:justify;">
<li> <strong><em>The DATETIMEOFFSET Type</em></strong>: DATETIMEOFFSET (<em>n</em>) is the time-zone-aware version of a datetime datatype. The name will appear less odd when you consider what it really is: a date + a time + a time-zone offset. The offset is based on how far behind or ahead you are from Coordinated Universal Time (UTC) time.</li>
</ul>
<ul class="unIndentedList" style="text-align:justify;">
<li> <strong><em>The DATETIME2 Type</em></strong>: It is an extension of the datetime type in earlier versions of SQL Server. This new datatype has a date range covering dates from January 1 of year 1 through December 31 of year 9999. This is a definite improvement over the 1753 lower boundary of the datetime datatype. DATETIME2 not only includes the larger date range, but also has a timestamp and the same fractional precision that TIME type provides</li>
</ul>
<p style="text-align:justify;"><strong>What are the Advantages of using CTE?</strong></p>
<ul class="unIndentedList" style="text-align:justify;">
<li> Using CTE improves the readability and makes maintenance of complex queries easy.</li>
<li> The query can be divided into separate, simple, logical building blocks which can be then used to build more complex CTEs until final result set is generated.</li>
<li> CTE can be defined in functions, stored procedures, triggers or even views.</li>
<li> After a CTE is defined, it can be used as a Table or a View and can SELECT, INSERT, UPDATE or DELETE Data.</li>
</ul>
<p style="text-align:justify;">© Copyright 2000-2009<a title="Pinal Dave" href="http://www.pinaldave.com/" target="_blank"> Pinal Dave.</a> All Rights Reserved. <a href="http://blog.sqlauthority.com/" target="_blank">SQLAuthority.com</a></p>
<p style="text-align:justify;">Reference : <strong>Pinal Dave (</strong><a href="http://blog.SQLAuthority.com" target="_blank"><strong>http://blog.SQLAuthority.com</strong></a><strong>)</strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlauthority.wordpress.com/1008/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlauthority.wordpress.com/1008/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/1008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/1008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/1008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/1008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/1008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/1008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/1008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/1008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/1008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/1008/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&blog=668536&post=1008&subd=sqlauthority&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2008/09/17/sql-server-2008-interview-questions-and-answers-part-6/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
	</channel>
</rss>