<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Interview &#187; Database Questions</title>
	<atom:link href="http://interview.msdotnetheaven.com/topics/database-question-answer/feed" rel="self" type="application/rss+xml" />
	<link>http://interview.msdotnetheaven.com</link>
	<description>Best place for interview preparation</description>
	<lastBuildDate>Sat, 21 May 2011 21:43:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Write query to get custom results</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html#comments</comments>
		<pubDate>Mon, 08 Feb 2010 10:30:01 +0000</pubDate>
		<dc:creator>smartbrain</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[MsSql Server]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[Sql Server 2005]]></category>

		<guid isPermaLink="false">http://interview.msdotnetheaven.com/?p=659</guid>
		<description><![CDATA[This question is asked in recent interview, following is the scenario:
Q. I have a following table :



University
UtoTal
Status
StatusCnt


U1
100
Pending
20


U1
100
Active
20


U1
100
Deferred
60


U2
60
Pending
20


U2
60
Active
20


U2
60
Deferred
20



I want results as :



University
UtoTal
Status
StatusCnt


U1
100
Pending
20




Active
20




Deferred
60


U2
60
Pending
20




Active
20




Deferred
20



Ans: At the time of interview I wasn&#8217;t easy with the answer but I wrote a query, but interviewer not satisfied.
I got the following proper query/solution from one of my colleagues Mr. sandeep Walia:
declare @tbl table(university varchar(100),Utotals int, status varchar(100),statuscnt int)
insert into @tbl(university,Utotals,status,statuscnt)
select &#8216;u1&#8242;,100,&#8217;pending&#8217;,20
union all
select &#8216;u1&#8242;,100,&#8217;Active&#8217;,20
union all
select &#8216;u1&#8242;,100,&#8217;Deferred&#8217;,60
union all
select &#8216;u2&#8242;,60,&#8217;pending&#8217;,20
union all
select &#8216;u2&#8242;,60,&#8217;Active&#8217;,20
union all
select &#8216;u2&#8242;,60,&#8217;Deferred&#8217;,20
select * from @tbl;
with cte as (
SELECT ROW_NUMBER() OVER(PARTITION BY university ORDER BY university DESC) AS RowID,
*
FROM ...


Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/mainframe-vsam-question-answer/what-is-file-status-in-vsam.html' rel='bookmark' title='Permanent Link: What is File Status in VSAM?'>What is File Status in VSAM?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This question is asked in recent interview, following is the scenario:</p>
<p>Q. I have a following table :</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="128" valign="top"><strong>University</strong></td>
<td width="128" valign="top"><strong>UtoTal</strong></td>
<td width="128" valign="top"><strong>Status</strong></td>
<td width="128" valign="top"><strong>StatusCnt</strong></td>
</tr>
<tr>
<td width="128" valign="top">U1</td>
<td width="128" valign="top">100</td>
<td width="128" valign="top">Pending</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top">U1</td>
<td width="128" valign="top">100</td>
<td width="128" valign="top">Active</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top">U1</td>
<td width="128" valign="top">100</td>
<td width="128" valign="top">Deferred</td>
<td width="128" valign="top">60</td>
</tr>
<tr>
<td width="128" valign="top">U2</td>
<td width="128" valign="top">60</td>
<td width="128" valign="top">Pending</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top">U2</td>
<td width="128" valign="top">60</td>
<td width="128" valign="top">Active</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top">U2</td>
<td width="128" valign="top">60</td>
<td width="128" valign="top">Deferred</td>
<td width="128" valign="top">20</td>
</tr>
</tbody>
</table>
<p>I want results as :</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="128" valign="top"><strong>University</strong></td>
<td width="128" valign="top"><strong>UtoTal</strong></td>
<td width="128" valign="top"><strong>Status</strong></td>
<td width="128" valign="top"><strong>StatusCnt</strong></td>
</tr>
<tr>
<td width="128" valign="top">U1</td>
<td width="128" valign="top">100</td>
<td width="128" valign="top">Pending</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top"></td>
<td width="128" valign="top"></td>
<td width="128" valign="top">Active</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top"></td>
<td width="128" valign="top"></td>
<td width="128" valign="top">Deferred</td>
<td width="128" valign="top">60</td>
</tr>
<tr>
<td width="128" valign="top">U2</td>
<td width="128" valign="top">60</td>
<td width="128" valign="top">Pending</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top"></td>
<td width="128" valign="top"></td>
<td width="128" valign="top">Active</td>
<td width="128" valign="top">20</td>
</tr>
<tr>
<td width="128" valign="top"></td>
<td width="128" valign="top"></td>
<td width="128" valign="top">Deferred</td>
<td width="128" valign="top">20</td>
</tr>
</tbody>
</table>
<p><strong>Ans:</strong> At the time of interview I wasn&#8217;t easy with the answer but I wrote a query, but interviewer not satisfied.</p>
<p>I got the following proper query/solution from one of my colleagues <strong>Mr. sandeep Walia:</strong></p>
<blockquote><p>declare @tbl table(university varchar(100),Utotals int, status varchar(100),statuscnt int)</p>
<p>insert into @tbl(university,Utotals,status,statuscnt)</p>
<p>select &#8216;u1&#8242;,100,&#8217;pending&#8217;,20</p>
<p>union all</p>
<p>select &#8216;u1&#8242;,100,&#8217;Active&#8217;,20</p>
<p>union all</p>
<p>select &#8216;u1&#8242;,100,&#8217;Deferred&#8217;,60</p>
<p>union all</p>
<p>select &#8216;u2&#8242;,60,&#8217;pending&#8217;,20</p>
<p>union all</p>
<p>select &#8216;u2&#8242;,60,&#8217;Active&#8217;,20</p>
<p>union all</p>
<p>select &#8216;u2&#8242;,60,&#8217;Deferred&#8217;,20</p>
<p>select * from @tbl;</p>
<p>with cte as (</p>
<p>SELECT ROW_NUMBER() OVER(PARTITION BY university ORDER BY university DESC) AS RowID,</p>
<p>*</p>
<p>FROM @tbl</p>
<p>)</p>
<p>SELECT case when rowid=1 then university else null end university,case when rowid=1 then Utotals else null end Utotals,status,statuscnt</p>
<p>FROM cte</p></blockquote>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Write+query+to+get+custom+results+http%3A%2F%2Ftinyurl.com%2F5szoj2s" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Write+query+to+get+custom+results+http%3A%2F%2Ftinyurl.com%2F5szoj2s" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=659&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/mainframe-vsam-question-answer/what-is-file-status-in-vsam.html' rel='bookmark' title='Permanent Link: What is File Status in VSAM?'>What is File Status in VSAM?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create dynamic query with dynamic joins</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html#comments</comments>
		<pubDate>Thu, 04 Feb 2010 15:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[MsSql Server]]></category>
		<category><![CDATA[dynamic joins]]></category>
		<category><![CDATA[dynamic query]]></category>
		<category><![CDATA[joins]]></category>
		<category><![CDATA[Sql2005]]></category>

		<guid isPermaLink="false">http://interview.msdotnetheaven.com/?p=656</guid>
		<description><![CDATA[Q. Here is the scenario:

declare @tt table(col1 varchar(10), joinexp varchar(100))
insert into @tt
select &#8216;c1&#8242;,&#8217;join table2 on table1.id = table1.id&#8217;
union all
select &#8216;c2&#8242;,&#8217;join table3 on table2.id = table1.id&#8217;
union all
select &#8216;c3&#8242;,&#8217;join table4 on table3.id = table1.id&#8217;
union all
select &#8216;c4&#8242;,&#8217;join table5 on table5.id = table1.id&#8217;
union all
select &#8216;c5&#8242;,NULL
union all
select &#8216;c6&#8242;,NULL
declare @str varchar(1000)
set @str = &#8216;Select c1,c4,c5,c8,c9 from table1&#8242;
declare @tt table(col1 varchar(10), joinexp varchar(100))insert into @ttselect &#8216;c1&#8242;,&#8217;join table2 on table1.id = table1.id&#8217;union allselect &#8216;c2&#8242;,&#8217;join table3 on table2.id = table1.id&#8217;union allselect &#8216;c3&#8242;,&#8217;join table4 on table3.id = table1.id&#8217;union allselect &#8216;c4&#8242;,&#8217;join table5 on table5.id = table1.id&#8217;union allselect &#8216;c5&#8242;,NULLunion allselect &#8216;c6&#8242;,NULL
declare @str ...


Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/mainframe-db2-question-answer/what-is-the-syntax-required-for-the-creation-of-a-cursor.html' rel='bookmark' title='Permanent Link: What is the syntax required for the creation of a cursor?'>What is the syntax required for the creation of a cursor?</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Q. Here is the scenario:</p>
<blockquote>
<div id="_mcePaste">declare @tt table(col1 varchar(10), joinexp varchar(100))</div>
<div id="_mcePaste">insert into @tt</div>
<div id="_mcePaste">select &#8216;c1&#8242;,&#8217;join table2 on table1.id = table1.id&#8217;</div>
<div id="_mcePaste">union all</div>
<div id="_mcePaste">select &#8216;c2&#8242;,&#8217;join table3 on table2.id = table1.id&#8217;</div>
<div id="_mcePaste">union all</div>
<div id="_mcePaste">select &#8216;c3&#8242;,&#8217;join table4 on table3.id = table1.id&#8217;</div>
<div id="_mcePaste">union all</div>
<div id="_mcePaste">select &#8216;c4&#8242;,&#8217;join table5 on table5.id = table1.id&#8217;</div>
<div id="_mcePaste">union all</div>
<div id="_mcePaste">select &#8216;c5&#8242;,NULL</div>
<div id="_mcePaste">union all</div>
<div id="_mcePaste">select &#8216;c6&#8242;,NULL</div>
<div id="_mcePaste">declare @str varchar(1000)</div>
<div id="_mcePaste">set @str = &#8216;Select c1,c4,c5,c8,c9 from table1&#8242;</div>
<p>declare @tt table(col1 varchar(10), joinexp varchar(100))insert into @ttselect &#8216;c1&#8242;,&#8217;join table2 on table1.id = table1.id&#8217;union allselect &#8216;c2&#8242;,&#8217;join table3 on table2.id = table1.id&#8217;union allselect &#8216;c3&#8242;,&#8217;join table4 on table3.id = table1.id&#8217;union allselect &#8216;c4&#8242;,&#8217;join table5 on table5.id = table1.id&#8217;union allselect &#8216;c5&#8242;,NULLunion allselect &#8216;c6&#8242;,NULL<br />
declare @str varchar(1000)set @str = &#8216;Select c1,c4,c5,c8,c9 from table1&#8242;</p></blockquote>
<p>Now, in above create dynamic query with dynamic join with the subsequent column from C1,c4 etc.</p>
<blockquote><p>Ans: Select @str = @str + space(1) + joinexp</p>
<p>from @tt</p>
<p>where CharIndex(col1,@str) &gt; 0 and joinexp &lt;&gt;&#8221;</p>
<p>Select @str</p></blockquote>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Create+dynamic+query+with+dynamic+joins+http%3A%2F%2Ftinyurl.com%2F6f85nnc" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Create+dynamic+query+with+dynamic+joins+http%3A%2F%2Ftinyurl.com%2F6f85nnc" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=656&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/mainframe-db2-question-answer/what-is-the-syntax-required-for-the-creation-of-a-cursor.html' rel='bookmark' title='Permanent Link: What is the syntax required for the creation of a cursor?'>What is the syntax required for the creation of a cursor?</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How can I get the date of Last Monday of specified week?</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/how-can-i-get-the-date-of-last-monday-of-specified-week.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/how-can-i-get-the-date-of-last-monday-of-specified-week.html#comments</comments>
		<pubDate>Fri, 22 Jan 2010 16:50:47 +0000</pubDate>
		<dc:creator>smartbrain</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[MsSql Server]]></category>
		<category><![CDATA[sql interview question]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://interview.msdotnetheaven.com/?p=640</guid>
		<description><![CDATA[The query is asked in my recent interview and the same I want to share with you. If anyone has better solution(corrected by Sandeep Walia)  please share here:
declare @dt datetime
set @dt=&#8217;1/1/2010&#8242; &#8211;Want to know January&#8217;s Last Monday Date
SELECT dateadd(d,-datepart(dw,DATEADD(d, -datepart(d,dateadd(mm,1,@dt)),dateadd(mm,1,@dt))-1)+1,DATEADD(d, -datepart(d,dateadd(mm,1,@dt)),dateadd(mm,1,@dt)))
  Tweet This Post

Related posts:Write query to get custom results
Change date format mm/dd/yy to dd/mm/yy using query?
Create dynamic query with dynamic joins



Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The query is asked in my recent interview and the same I want to share with you. If anyone has better solution(corrected by Sandeep Walia)  please share here:</p>
<blockquote><p>declare @dt datetime</p>
<p>set @dt=&#8217;1/1/2010&#8242; &#8211;Want to know January&#8217;s Last Monday Date</p>
<p>SELECT dateadd(d,-datepart(dw,DATEADD(d, -datepart(d,dateadd(mm,1,@dt)),dateadd(mm,1,@dt))-1)+1,DATEADD(d, -datepart(d,dateadd(mm,1,@dt)),dateadd(mm,1,@dt)))</p></blockquote>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=How+can+I+get+the+date+of+Last+Monday+of+specified+week%3F+http%3A%2F%2Ftinyurl.com%2F4upd42e" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=How+can+I+get+the+date+of+Last+Monday+of+specified+week%3F+http%3A%2F%2Ftinyurl.com%2F4upd42e" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=640&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/how-can-i-get-the-date-of-last-monday-of-specified-week.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change date format mm/dd/yy to dd/mm/yy using query?</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html#comments</comments>
		<pubDate>Fri, 28 Aug 2009 19:30:29 +0000</pubDate>
		<dc:creator>meghna</dc:creator>
				<category><![CDATA[MsSql Server]]></category>
		<category><![CDATA[interview questions and answers]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.interview.msdotnetheaven.com/?p=530</guid>
		<description><![CDATA[Sql server stores date as yyyy/dd/mm and returns with time.
use following query:
Select CAST(DAY(GETDATE()) AS VARCHAR(2)) + &#8216;/&#8217; + CAST(MONTH(GETDATE()) AS VARCHAR(2)) + &#8216;/ &#8216; + CAST(YEAR(GETDATE()) AS VARCHAR(4)) AS DATE
Result will be : in mm/dd/yyy
  Tweet This Post

Related posts:Create dynamic query with dynamic joins
Write query to get custom results
How can I get the date of Last Monday of specified week?



Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/how-can-i-get-the-date-of-last-monday-of-specified-week.html' rel='bookmark' title='Permanent Link: How can I get the date of Last Monday of specified week?'>How can I get the date of Last Monday of specified week?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Sql server stores date as yyyy/dd/mm and returns with time.</p>
<p>use following query:</p>
<p>Select CAST(DAY(GETDATE()) AS VARCHAR(2)) + &#8216;/&#8217; + CAST(MONTH(GETDATE()) AS VARCHAR(2)) + &#8216;/ &#8216; + CAST(YEAR(GETDATE()) AS VARCHAR(4)) AS DATE</p>
<p>Result will be : in mm/dd/yyy</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Change+date+format+mm%2Fdd%2Fyy+to+dd%2Fmm%2Fyy+using+query%3F+http%3A%2F%2Ftinyurl.com%2F4w324hu" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Change+date+format+mm%2Fdd%2Fyy+to+dd%2Fmm%2Fyy+using+query%3F+http%3A%2F%2Ftinyurl.com%2F4w324hu" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=530&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/how-can-i-get-the-date-of-last-monday-of-specified-week.html' rel='bookmark' title='Permanent Link: How can I get the date of Last Monday of specified week?'>How can I get the date of Last Monday of specified week?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create a new table with datafrom another table</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/how-to-create-a-new-table-with-datafrom-another-table.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/how-to-create-a-new-table-with-datafrom-another-table.html#comments</comments>
		<pubDate>Fri, 21 Aug 2009 06:04:46 +0000</pubDate>
		<dc:creator>meghna</dc:creator>
				<category><![CDATA[MsSql Server]]></category>
		<category><![CDATA[insert]]></category>
		<category><![CDATA[interview questions and answers]]></category>
		<category><![CDATA[MsSql]]></category>

		<guid isPermaLink="false">http://www.interview.msdotnetheaven.com/?p=524</guid>
		<description><![CDATA[Simply, you can use &#8216;Insert Into&#8216;
ex:
Create Table newTable (id VarChar(10))
Insert Into newTable Select id from oldTable
  Tweet This Post

Related posts:Create dynamic query with dynamic joins
Change date format mm/dd/yy to dd/mm/yy using query?
Write query to get custom results



Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Simply, you can use &#8216;<strong>Insert Into</strong>&#8216;</p>
<p>ex:</p>
<p>Create Table newTable (id VarChar(10))</p>
<p>Insert Into newTable Select id from oldTable</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=How+to+create+a+new+table+with+datafrom+another+table+http%3A%2F%2Ftinyurl.com%2F4b2ses5" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=How+to+create+a+new+table+with+datafrom+another+table+http%3A%2F%2Ftinyurl.com%2F4b2ses5" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=524&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/create-dynamic-query-with-dynamic-joins.html' rel='bookmark' title='Permanent Link: Create dynamic query with dynamic joins'>Create dynamic query with dynamic joins</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/change-date-format-mmddyy-to-ddmmyy-using-query.html' rel='bookmark' title='Permanent Link: Change date format mm/dd/yy to dd/mm/yy using query?'>Change date format mm/dd/yy to dd/mm/yy using query?</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/write-query-to-get-custom-results.html' rel='bookmark' title='Permanent Link: Write query to get custom results'>Write query to get custom results</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/mssql-question-answer/how-to-create-a-new-table-with-datafrom-another-table.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB2 : SQL Codes and Description</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/db2-sql-codes-and-description.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/db2-sql-codes-and-description.html#comments</comments>
		<pubDate>Sat, 08 Aug 2009 18:46:04 +0000</pubDate>
		<dc:creator>neerajmehta1984</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Mainframe]]></category>
		<category><![CDATA[Description]]></category>
		<category><![CDATA[IBM Main frame]]></category>
		<category><![CDATA[interview questions]]></category>
		<category><![CDATA[SQL Codes]]></category>

		<guid isPermaLink="false">http://www.interview.msdotnetheaven.com/?p=61</guid>
		<description><![CDATA[



SQL   CODESÃ‚Â Ã‚Â Ã‚Â  Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â DESCRIPTION






000 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Sql Statement finished   succesfully


+100 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  No rows satisfied the sql   statement


+117 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  No of values being inserted   is not equal to no. ...


Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; I'>Interview Questions DB2 : Part &#8211; I</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/mainframe-db2-question-answer/what-is-a-foreign-key.html' rel='bookmark' title='Permanent Link: What is a foreign key?'>What is a foreign key?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="662" valign="top">
<h3>SQL   CODESÃ‚Â Ã‚Â Ã‚Â  Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â DESCRIPTION</h3>
</td>
</tr>
<tr>
<td width="662" valign="top"></td>
</tr>
<tr>
<td width="662" valign="top">000 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Sql Statement finished   succesfully</td>
</tr>
<tr>
<td width="662" valign="top">+100 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  No rows satisfied the sql   statement</td>
</tr>
<tr>
<td width="662" valign="top">+117 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  No of values being inserted   is not equal to no. of Ã‚Â columns in the table   being inserted to</td>
</tr>
<tr>
<td width="662" valign="top">+162 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Named table space is placed   in check pending Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  status</td>
</tr>
<tr>
<td width="662" valign="top">+204 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Named   Object is not defined to Db2</td>
</tr>
<tr>
<td width="662" valign="top">+205 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Named column does not exist in   the named table</td>
</tr>
<tr>
<td width="662" valign="top">+206 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â Named column does not exist   in any table which is Ã‚Â named in the sql   statement</td>
</tr>
<tr>
<td width="662" valign="top">+625 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â Table defination marked   incomplete because Ã‚Â  Ã‚Â  primary Key index was   dropped</td>
</tr>
<tr>
<td width="662" valign="top">+802 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â Data Exception error caused   by data Ã‚Â  Ã‚Â overflow/divide   Exception</td>
</tr>
<tr>
<td width="662" valign="top">-007 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Sql Statement contains   illegal character</td>
</tr>
<tr>
<td width="662" valign="top">-029 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  INTO clause is required</td>
</tr>
<tr>
<td width="662" valign="top">-060 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Specified Data type has an   invalid length/scale Ã‚Â specification</td>
</tr>
<tr>
<td width="662" valign="top">-084 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Sql statement canÃ¢â‚¬â„¢t be   excuted because it is invalid for Dynamic sql/is an   sql /ds statement</td>
</tr>
<tr>
<td width="662" valign="top">-101 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Sql statement exceeds an   established DB2 limit Ã‚Â (Too many tables / Too   many bytes in Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â the statement)</td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="662" valign="top">
<h3>Date/Time</h3>
</td>
</tr>
<tr>
<td width="662" valign="top"></td>
</tr>
<tr>
<td width="662" valign="top">-180 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Syntax for string   representation ofÃ‚Â  Date/Time Ã‚Â value   is invalid</td>
</tr>
<tr>
<td width="662" valign="top">-181 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  String   representation of Date/Time value is invalid</td>
</tr>
<tr>
<td width="662" valign="top">-182 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Date/Time value in an   arithmetic expression is Ã‚Â  Ã‚Â  Ã‚Â  invalid</td>
</tr>
<tr>
<td width="662" valign="top">-183 Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â Result of arithmetic   expression Returns a Ã‚Â  Date/Time value that   is not in the range of valid Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â values</td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="662" valign="top">
<h2>Cursors</h2>
</td>
</tr>
<tr>
<td width="662" valign="top"></td>
</tr>
<tr>
<td width="662" valign="top">-501Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Cursor   must be opened before attempting to fetch Ã‚Â  from itÃ‚Â  or close it</td>
</tr>
<tr>
<td width="662" valign="top">-502Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Cursor   canÃ¢â‚¬â„¢t opened twise without first closing it</td>
</tr>
<tr>
<td width="662" valign="top">-503Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Column   canÃ¢â‚¬â„¢t be updated because it was not specified in Ã‚Â the FOR UPDATE OFF   clause of the cursor Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â from it wasÃ‚Â fetched</td>
</tr>
<tr>
<td width="662" valign="top">-504Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Cursor   canÃ¢â‚¬â„¢t be referenced because it defined to Ã‚Â  the program</td>
</tr>
<tr>
<td width="662" valign="top">-507Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Cursor   must be opened before attempting to Ã‚Â  Ã‚Â update/deleteÃ‚Â  WHERE CURRENT OF</td>
</tr>
<tr>
<td width="662" valign="top">-508Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  You   canÃ¢â‚¬â„¢t update or delete because referencedÃ‚Â cursor is not positioned in a   data row</td>
</tr>
<tr>
<td width="662" valign="top">-509Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  You   canÃ¢â‚¬â„¢t upate from a different table than the oneÃ‚Â specified   on the cursor referenced by Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â WHEREÃ‚Â CURRENT   OF clause</td>
</tr>
</tbody>
</table>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="662" valign="top">
<h2>Referential Integrity</h2>
</td>
</tr>
<tr>
<td width="662" valign="top"></td>
</tr>
<tr>
<td width="662" valign="top">-530Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Invalid   foreign key was specified for specified Ã‚Â  constraint name</td>
</tr>
<tr>
<td width="662" valign="top">-531Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Primary   key value canÃ¢â‚¬â„¢t be updated if foreign keys Ã‚Â currently exist that   reference that value</td>
</tr>
<tr>
<td width="662" valign="top">-532Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Deletion   violates the named referential constraint</td>
</tr>
<tr>
<td width="662" valign="top">-533Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Multiple   row insert is invalid; Attempting to insert Ã‚Â  Ã‚Â multiple   rows into a self referencing table</td>
</tr>
<tr>
<td width="662" valign="top">-534Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Update   statement changing primary key columnÃ‚Â canÃ¢â‚¬â„¢t   be used to update more than one row at a time</td>
</tr>
<tr>
<td width="662" valign="top">-535Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  WHERE   CURRENT OF canÃ¢â‚¬â„¢t be specified when deleting from aÃ‚Â self referencing table or updating Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â primary key column</td>
</tr>
<tr>
<td width="662" valign="top">-536Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Delete   statement is invalid due to referential Ã‚Â constraints existing   for the specified table</td>
</tr>
<tr>
<td width="662" valign="top">-537Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Single   column canÃ¢â‚¬â„¢tÃ‚Â  appear more than once inÃ‚Â foreign/primary   key clause specification</td>
</tr>
<tr>
<td width="662" valign="top">-538Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Foreign   key is invalid. Because it does not conformÃ‚Â    toÃ‚Â the definition of   referenced table primary key</td>
</tr>
<tr>
<td width="662" valign="top">-539Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Foreign   key canÃ¢â‚¬â„¢t be defined because theÃ‚Â referenced   table does not have primary key</td>
</tr>
<tr>
<td width="662" valign="top">-540Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Table   definition is incomplete until unique index isÃ‚Â created for the   primary key</td>
</tr>
<tr>
<td width="662" valign="top">-551Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  User   is attempting to perform an operation on the Ã‚Â specified object for   which user is not authorised or Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Table does not exist</td>
</tr>
<tr>
<td width="662" valign="top">-601Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  An attempt   was made to create an object thatÃ‚Â already   exists</td>
</tr>
<tr>
<td width="662" valign="top">-602Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Too   many columns were specified in CREATE INDEXÃ‚Â statement</td>
</tr>
<tr>
<td width="662" valign="top">-603Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Unique   index cannot be created because duplicates were found</td>
</tr>
<tr>
<td width="662" valign="top">-607Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  INSERT,UPDATE,DELETE   canÃ¢â‚¬â„¢t be issued as written againstÃ‚Â the DB2 catalogue   tables</td>
</tr>
<tr>
<td width="662" valign="top">-612Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Duplicate   column names are permitted in single table</td>
</tr>
<tr>
<td width="662" valign="top">-803Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Row   canÃ¢â‚¬â„¢t be inserted because it would violate the constraints   of the unique index</td>
</tr>
<tr>
<td width="662" valign="top">-818Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Time Stamp   Mismatch</td>
</tr>
<tr>
<td width="662" valign="top">-904Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Specified   resource is unavailable</td>
</tr>
<tr>
<td width="662" valign="top">-911Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Current   unit of work hasÃ‚Â  been Rolled back</td>
</tr>
<tr>
<td width="662" valign="top">-913Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Execution   is unsuccessful due toÃ‚Â DEADLOCK/TIME   OUT</td>
</tr>
<tr>
<td width="662" valign="top">-922Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Connection   authorisation failure. Attempt made toÃ‚Â access   DB2 from TSO, CICS,IMS and appropriate Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  attachmentÃ‚Â facility is inactive</td>
</tr>
</tbody>
</table>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=DB2+%3A+SQL+Codes+and+Description+http%3A%2F%2Ftinyurl.com%2F3lsjok9" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=DB2+%3A+SQL+Codes+and+Description+http%3A%2F%2Ftinyurl.com%2F3lsjok9" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=61&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; I'>Interview Questions DB2 : Part &#8211; I</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/mainframe-db2-question-answer/what-is-a-foreign-key.html' rel='bookmark' title='Permanent Link: What is a foreign key?'>What is a foreign key?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/db2-sql-codes-and-description.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB2 understanding : Part Ã¢â‚¬â€œ II</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html#comments</comments>
		<pubDate>Sat, 08 Aug 2009 18:28:40 +0000</pubDate>
		<dc:creator>neerajmehta1984</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Mainframe]]></category>
		<category><![CDATA[DB2 interview questions]]></category>
		<category><![CDATA[DB2 Utilities]]></category>
		<category><![CDATA[DCLGEN]]></category>
		<category><![CDATA[IBM Main frame]]></category>
		<category><![CDATA[Interview question collection]]></category>
		<category><![CDATA[interview questions]]></category>
		<category><![CDATA[LOCKS]]></category>
		<category><![CDATA[Program preparation and execution]]></category>
		<category><![CDATA[QMF]]></category>
		<category><![CDATA[SPUFI]]></category>

		<guid isPermaLink="false">http://www.interview.msdotnetheaven.com/?p=57</guid>
		<description><![CDATA[DB2 understanding : Part Ã¢â‚¬â€œ II


Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-i.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part &#8211; I'>DB2 understanding : Part &#8211; I</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; I'>Interview Questions DB2 : Part &#8211; I</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong><span style="text-decoration: underline;">The whole series us updated by Deepthi</span></strong><strong></strong></p>
<h2>Topics covered</h2>
<ul>
<li>QMF</li>
<li>SPUFI</li>
<li>Program      preparation and execution</li>
<li>DCLGEN</li>
<li>LOCKS</li>
<li>DB2      Utilities</li>
</ul>
<p><strong>DCLGEN</strong><strong></strong></p>
<p>DCLGEN is a facility that is used to generate SQL statements that describe a table or view. These table descriptions are then used to check the validity of other SQL statements at precompile time. DCLGENÃ‚Â  uses table declaration to build a host language structure, whichÃ‚Â  is used by the DB2 precompilerÃ‚Â  to verify that correct column names and data types have been specified in the SQL statement.</p>
<p><strong>LOCKS</strong><strong></strong></p>
<ul>
<li>DB2 uses      locks to control concurrence and prevent lost updates.</li>
<li>Locks      prevent one program from accessing data that anotherÃ‚Â  program has      changed but not yet committed.</li>
<li>DB2 acquires      all locks implicitly under DB2 control.
<ul>
<li>Lock can be       obtainedÃ‚Â  ==&gt;</li>
</ul>
</li>
</ul>
<ul></ul>
<ul>
<li>
<ul>
<li>Implicitly       &#8211; by the system</li>
<li>Explicitly       &#8211; by the user</li>
</ul>
</li>
</ul>
<p>There are 2 kinds of locks :</p>
<ul>
<li><strong>SharedÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â       S</strong><strong></strong></li>
<li><strong>ExclusiveÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â       X</strong><strong></strong></li>
</ul>
<p><strong>SHARE MODE Lock :</strong><strong></strong></p>
<ul>
<li>Is used for      querying consistent data</li>
<li>Prevents      other users from updating data, you are reading</li>
<li>Prevents      other users from putting EXCLUSIVE mode lockÃ‚Â  on the table</li>
<li>Lets other      users read the data</li>
<li>Locks the      whole table</li>
</ul>
<p><strong><span style="text-decoration: underline;">ExampleÃ‚Â  :</span></strong><strong></strong></p>
<p>LOCK TABLE EMPLOYEE</p>
<p>INÃ‚Â  SHAREÃ‚Â  MODE ;</p>
<p><strong>EXCLUSIVE MODE lock :</strong></p>
<ul>
<li>Is used for      changing data</li>
<li>Prevents      other users from updating data, youÃ¢â‚¬â„¢re reading</li>
<li>Prevents      other users from putting ANY lock on the table</li>
<li>Lets other      users read the data</li>
<li>Does not      guarantee current data</li>
<li>Locks the      whole table</li>
</ul>
<p><strong><span style="text-decoration: underline;">Example</span></strong><strong></strong> :</p>
<p>LOCK TABLE EMPLOYEEÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  INÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Ã‚Â  EXCLUSIVE MODE ;</p>
<p><strong><em>Locks can be obtained implicitly or explicitly.</em></strong><strong><em></em></strong></p>
<p>Implicit lock is issued by the system itself.</p>
<p><strong><span style="text-decoration: underline;">DB2 provides facilities for explicit locking :</span></strong><strong></strong></p>
<ul>
<li>The SQL      statement LOCK TABLE</li>
<li>The      ISOLATION parameter on the BIND command</li>
<li>The      tablespace LOCKSIZE parameter</li>
<li>The      ACQUIRE/RELEASE parameters on the BIND command</li>
</ul>
<p><strong>DB2 UTILITIES</strong><strong></strong></p>
<ul>
<li>LOAD</li>
<li>IMAGECOPY</li>
<li>RECOVERY</li>
<li>REORG</li>
<li>RUNSTATS</li>
<li>CHECKS</li>
</ul>
<p><strong><span style="text-decoration: underline;">LOAD</span></strong><strong></strong></p>
<p>Use LOAD to load one or more tables of a table space. LOAD loads recordsÃ‚Â Ã‚Â Ã‚Â  into the tables and builds or extends any indexes defined on them. If theÃ‚Â Ã‚Â  table space already contains data, you can choose whether you want to addÃ‚Â Ã‚Â  the new data to the existing data or replace the existing data. The loadedÃ‚Â  data is processed by any edit or validation routine associated with theÃ‚Â Ã‚Â Ã‚Â Ã‚Â  table, and any field procedure associated with any column of the table.</p>
<p><strong><span style="text-decoration: underline;">REORG</span></strong><strong></strong></p>
<p>The REORG online utility reorganizes a table space or index to improve access performance and reclaim fragmented space. In addition, the utility can reorganize a single partition of either a partitioned index or aÃ‚Â  Ã‚Â partitioned table space. You can specify the degree of access to your data during reorganization. If you specify REORG UNLOAD ONLY, the data is unloaded in a format that is acceptable to the LOAD utility of the same DB2 subsystem.</p>
<p><strong>Output</strong><strong></strong>: If the table space or partition has the COMPRESS YES attributes, then the data is compressed when reloaded. If you specify the KEEPDICTIONARY option of REORG, the current dictionary is used; otherwiseÃ‚Â  a new dictionary is built.</p>
<p><strong>REORG TABLESPACE</strong><strong></strong> can be executed on the table spaces in the DB2 catalog</p>
<p>database (DSNDB06) and some table spaces in the directory database</p>
<p>(DSNDB01).Ã‚Â  It cannot be executed on any table space in the DSNDB07</p>
<p>database.</p>
<p><strong>Authorization Required</strong><strong></strong>: To execute this utility on a user table space or</p>
<p>index, the privilege set of the process must include one of the following:</p>
<ul>
<li>REORG      privilege for the database</li>
<li>DBADM or      DBCTRL authority for the database</li>
<li>SYSCTRL      authority</li>
<li>SYSADM      authority.</li>
</ul>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=DB2+understanding+%3A+Part+%C3%83%C2%A2%C3%A2%E2%80%9A%C2%AC%C3%A2%E2%82%AC%C5%93+II+http%3A%2F%2Ftinyurl.com%2F6x4ad4t" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=DB2+understanding+%3A+Part+%C3%83%C2%A2%C3%A2%E2%80%9A%C2%AC%C3%A2%E2%82%AC%C5%93+II+http%3A%2F%2Ftinyurl.com%2F6x4ad4t" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=57&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-i.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part &#8211; I'>DB2 understanding : Part &#8211; I</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; I'>Interview Questions DB2 : Part &#8211; I</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB2 understanding : Part &#8211; I</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-i.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-i.html#comments</comments>
		<pubDate>Sat, 08 Aug 2009 18:07:35 +0000</pubDate>
		<dc:creator>neerajmehta1984</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Mainframe]]></category>
		<category><![CDATA[DB2 interview questions]]></category>
		<category><![CDATA[DB2 Utilities]]></category>
		<category><![CDATA[DCLGEN]]></category>
		<category><![CDATA[IBM Main frame]]></category>
		<category><![CDATA[Interview question collection]]></category>
		<category><![CDATA[interview questions]]></category>
		<category><![CDATA[LOCKS]]></category>
		<category><![CDATA[Program preparation and execution]]></category>
		<category><![CDATA[QMF]]></category>
		<category><![CDATA[SPUFI]]></category>

		<guid isPermaLink="false">http://www.interview.msdotnetheaven.com/?p=46</guid>
		<description><![CDATA[DB2 understanding : Part - I


Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part Ã¢â‚¬â€œ II'>DB2 understanding : Part Ã¢â‚¬â€œ II</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/cobol-interview-questions-unsolved.html' rel='bookmark' title='Permanent Link: Cobol Interview Questions &#8211; unsolved'>Cobol Interview Questions &#8211; unsolved</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong><span style="text-decoration: underline;">The whole series us updated by Deepthi</span></strong></p>
<h2><span style="font-weight: normal;">Topics covered</span></h2>
<ul>
<li> QMF</li>
<li>SPUFI</li>
<li>Program preparation and execution</li>
<li>DCLGEN</li>
<li>LOCKS</li>
<li>DB2 Utilities</li>
</ul>
<p><strong><span style="text-decoration: underline;">QMF</span></strong></p>
<p><strong> Description</strong>: <em>QMF = Query Management Facility</em></p>
<p>An <strong>IBM </strong>database management tool that allows extensive interactive query and report writing support.Ã‚Â  It runsÃ‚Â Ã‚Â Ã‚Â Ã‚Â  under the control of the Interactive System ProductivityÃ‚Â  Facility (<strong>ISPF</strong>), which in turn runs under Virtual MachineÃ‚Â Ã‚Â  (<strong>VM/CMS</strong>) or Time Sharing Option (<strong>TSO</strong>) on host computers.</p>
<p><strong><span style="text-decoration: underline;">SPUFI</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p><strong> Description</strong>: <em>SPUFI = SQL Processing Using File Input</em></p>
<p>A facility of the TSO attachment subcomponent that enablesÃ‚Â Ã‚Â  the DB2I user to execute SQL statements without embeddingÃ‚Â Ã‚Â  them in an application program.</p>
<ul>
<li> SPUFI requires that SQL statements to be executed be storedÃ‚Â in a data set. One way to use SPUFI is to create the data set prior to executing</li>
<li>SPUFI.Ã‚Â  We can make any desired changes to the data set using editingÃ‚Â facilities provided by SPUFI before executing the statements stored in it.</li>
<li> Alternatively, we can begin a SPUFI session and use the editing facilities of SPUFI to create a data set into which we can place our SQL statements.</li>
<li>As SQL statements are processed by SPUFI, the results they generateÃ‚Â are stored in a data set. The stored data includes a copy of each SQLÃ‚Â statement followed by its results.</li>
<li>For a SELECT statement, the results include both the data retrieved and the value of SQLCODE that is returned.</li>
<li>By invoking the BROWSE option, we can cause the output data set to be displayed on the terminal. We can use the ISPF browse facilities toÃ‚Â move around within the displayed data.</li>
<li>SPUFI also provides limited formatting options that we can use toÃ‚Â specify how the data in the output data set is displayed or printed.</li>
</ul>
<p>These formatting options can be set using the <strong>SPUFI </strong>defaults panel.</p>
<p><strong><span style="text-decoration: underline;">PROGRAM PREPARATIONÃ‚Â  AND EXECUTION</span></strong></p>
<ul>
<li>Precompile</li>
<li>Compile</li>
<li>Link-edit</li>
<li>Bind/Rebind</li>
<li>Execution</li>
</ul>
<p><strong><span style="text-decoration: underline;"> Languages that can be used with SQL</span> :</strong></p>
<ul>
<li>Assembler</li>
<li>BASIC</li>
<li>COBOL</li>
<li>FORTRAN</li>
<li>PL/1</li>
<li>C</li>
</ul>
<p><strong><span style="text-decoration: underline;">DB2 DATA TYPES AND EQUIVALENT COBOL FIELD DEFINITIONS</span></strong></p>
<p><strong><span style="text-decoration: underline;">DATA TYPES Ã‚Â  Ã‚Â  Ã‚Â KIND OF DATAÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  COBOL DEFINITION</span></strong><strong> </strong></p>
<p>SMALLINTÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Half word integerÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  PIC SÃ‚Â  9(4)Ã‚Â  COMP</p>
<p>INTEGERÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Full word integerÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  PIC SÃ‚Â  9(9)Ã‚Â  COMP</p>
<p>DECIMAL(p,s) Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â Packed decimal Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  PIC SÃ‚Â  9(7)V99 COMP-3</p>
<p>FLOAT(n)Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Floating point dataÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  (n &lt; 22) COMP-1</p>
<p>(22&lt;= 53) COMP-2</p>
<p>CHARÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Fixed-length character PICÃ‚Â  X(254)</p>
<p>VARCHARÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Variable-length characterÃ‚Â Ã‚Â  LÃ‚Â  PICÃ‚Â  S9(4) COMP</p>
<p>D PICÃ‚Â  X(254)</p>
<p>GRAPHICÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Fixed-lengthÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  PICÃ‚Â  G(n) DISPLAYÃ‚Â n=127</p>
<p>VARCHARÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Variable-length Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  LÃ‚Â  PICÃ‚Â  SÃ‚Â  9(4)Ã‚Â  COMPÃ‚Â TÃ‚Â  PIC G(127) Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  DISPLAY</p>
<p>DATEÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Date Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  PICÃ‚Â  X(10)</p>
<p>TIMEÃ‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â Ã‚Â  Time Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  PICÃ‚Â  X(8)</p>
<p>TIMESTAMP Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â Date and Time Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â  Ã‚Â PICÃ‚Â  X(26)</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=DB2+understanding+%3A+Part+%E2%80%93+I+http%3A%2F%2Ftinyurl.com%2F3qdkesq" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=DB2+understanding+%3A+Part+%E2%80%93+I+http%3A%2F%2Ftinyurl.com%2F3qdkesq" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=46&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part Ã¢â‚¬â€œ II'>DB2 understanding : Part Ã¢â‚¬â€œ II</a></li>
<li><a href='http://interview.msdotnetheaven.com/mainframe-question-and-answers/cobol-interview-questions-unsolved.html' rel='bookmark' title='Permanent Link: Cobol Interview Questions &#8211; unsolved'>Cobol Interview Questions &#8211; unsolved</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-i.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interview Questions DB2 : Part &#8211; II</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html#comments</comments>
		<pubDate>Sat, 08 Aug 2009 17:44:56 +0000</pubDate>
		<dc:creator>neerajmehta1984</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Mainframe]]></category>
		<category><![CDATA[Database Interview Questions]]></category>
		<category><![CDATA[IBM Main frame]]></category>
		<category><![CDATA[Interview question collections]]></category>
		<category><![CDATA[interview questions]]></category>
		<category><![CDATA[msdotneheaven]]></category>
		<category><![CDATA[Neeraj]]></category>

		<guid isPermaLink="false">http://www.interview.msdotnetheaven.com/?p=43</guid>
		<description><![CDATA[Interview Questions DB2 : Part - II


Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; I'>Interview Questions DB2 : Part &#8211; I</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part Ã¢â‚¬â€œ II'>DB2 understanding : Part Ã¢â‚¬â€œ II</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-sql-codes-and-description.html' rel='bookmark' title='Permanent Link: DB2 : SQL Codes and Description'>DB2 : SQL Codes and Description</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline; padding: 0px; margin: 0px;"><span style="color: #3366ff; padding: 0px; margin: 0px;">The following is the entire collection of DB2 interview questions:</span></span></p>
<p><strong>Q36. </strong> What are some characteristics of columns that benefit from  indexes?</p>
<p><strong>A36.</strong> <strong>Primary key</strong> and <strong>foreign key</strong> columns; Ã‚Â columns that  have unique values; columns that have aggregates computed frequently and columns  used to test the existence of a value.</p>
<p><strong>Q37. </strong> What is a <strong>composite index</strong> and how does it differ from a  <strong>multiple index</strong>?</p>
<p><strong>A37.</strong> A <strong>multiple index</strong> is not one index but two indexes for two  different columns of a table. Ã‚Â A <strong>composite index </strong>is one index made up of  combined values from two columns in a table. Ã‚Â If two columns in a table will  often be accessed together a <strong>composite index</strong> will be efficient.</p>
<p><strong>Q38. </strong> What is meant by <strong>index cardinality</strong>?</p>
<p><strong>A38.</strong> The number of distinct values for a column is called <strong>index  cardinality</strong>. Ã‚Â DB2&#8242;s RUNSTATS utility analyzes column value redundancy to  determine whether to use a tablespace or index scan to search for data.</p>
<p><strong>Q39. </strong> What is a <strong>clustered index</strong>?</p>
<p><strong>A39.</strong> For a <strong>clustered index</strong> DB2 maintains rows in the same  sequence as the columns in the index for as long as there is free space. DB2 can  then process that table in that order efficiently.</p>
<p><strong>Q40.</strong> What keyword does an SQL SELECT statement use for a string  search?</p>
<p><strong>A40.</strong> The LIKE keyword allows for string searches. Ã‚Â The % sign is used  as a wildcard.</p>
<p><strong>Q41.</strong> What are some sql <strong>aggregates</strong> and other <strong>built-in  functions</strong>?</p>
<p><strong>A41.</strong> The common <strong>aggregate, built-in functions</strong> are AVG, SUM,  MIN, MAX, COUNT and DISTINCT.</p>
<p><strong>Q42.</strong> How is the SUBSTR keyword used in sql?</p>
<p><strong>A42.</strong> SUBSTR is used for string manipulation with column name, first  position and string length used as arguments. Ã‚Â Eg. SUBSTR (NAME, 1 3) refers to  the first three characters in the column NAME.</p>
<p><strong>Q43.</strong> What are the three DB2 date and time data types and their  associated functions?</p>
<p><strong>A43.</strong> The three data types are DATE, TIME and TIMESTAMP. Ã‚Â CHAR can be  used to specify the format of each type. The DAYS function calculates the number  of days between two dates. Ã‚Â (It&#8217;s Y2K compliant).</p>
<p><strong>Q44.</strong> Explain <strong>transactions, commits</strong> and <strong>rollbacks</strong> in  DB2.</p>
<p><strong>A44.</strong> In DB2 a transaction typically requires a series of updates,  insertions and deletions that represent a <strong>logical unit of work</strong>. A  transaction puts an <strong>implicit lock </strong>on the DB2 data. Programmers can use  the COMMIT WORK statement to terminate the transaction creating smaller units  for recovery. Ã‚Â If the transaction fails DB2 uses the log to roll back values to  the start of the transaction or to the preceding commit point.</p>
<p><strong>Q45.</strong> What is <strong>deadlock</strong>?</p>
<p><strong>A45.</strong> <strong> Deadlock</strong> occurs when transactions executing at the same  time lock each other out of data that they need to complete their logical units  of work.</p>
<p><strong>Q46.</strong> What are the four lockable units for DB2?</p>
<p><strong>A46.</strong> DB2 imposes locks of four differing sizes: Ã‚Â pages, tables,  tablespace and for indexes subpage.</p>
<p><strong>Q47.</strong> What are the three lock types?</p>
<p><strong>A47.</strong> The three types are <strong>shared, update </strong>and <strong>exclusive</strong>.  Ã‚Â <strong>Shared locks</strong> allow two or more programs to read simultaneously but not  change the locked space. Ã‚Â An <strong>exclusive lock </strong>bars all other users from  accessing the space. Ã‚Â An <strong>update lock</strong> is less restrictive; it allows other  transactions to read or acquire shared locks on the space.</p>
<p><strong>Q48.</strong> What is <strong>isolation level</strong>?</p>
<p><strong>A48.</strong> SQL statements may return any number of rows, but most host  languages deal with one row at a time by declaring a <strong>cursor </strong>that presents  each row at a unique <strong>isolation level.</strong></p>
<p><strong>Q49.</strong> What is an <strong>intent lock</strong>?</p>
<p><strong>A49.</strong> An <strong>intent lock </strong>is at the table level for a segmented  tablespace or at the tablespace level for a nonsegmented tablespace. Ã‚Â They  indicate at the table or tablespace level the kinds of locks at lower levels.</p>
<p><strong>Q50.</strong> What is the difference between <strong>static</strong> and <strong>dynamic  sql</strong>?</p>
<p><strong>A50.</strong> <strong>Static sql </strong>is hard-coded in a program when the programmer  knows the statements to be executed. Ã‚Â For <strong>dynamic sql </strong>the program must  dynamically allocate memory to receive the query results.</p>
<p><strong>Q51.</strong> What is <strong>cursor stability</strong>?</p>
<p><strong>A51.</strong> <strong>Cursor stability</strong> means that DB2 takes a lock on the page  the cursor is accessing and releases the lock when the cursor moves to another  page.</p>
<p><strong>Q52.</strong> What is the significance of the CURSOR WITH HOLD clause in a  cursor declaration?</p>
<p><strong>A52.</strong> The clause avoids closing the cursor and repositioning it to the  last row processed when the cursor is reopened.</p>
<p><strong>Q53.</strong> What is the SQL Communications Area and what are some of its key  fields?</p>
<p><strong>A53.</strong> It is a data structure that must be included in any  host-language program using SQL. Ã‚Â It is used to pass feedback about the sql  operations to the program. Ã‚Â Fields are return codes, error messages, handling  codes and warnings.</p>
<p><strong>Q54.</strong> What is the purpose of the <strong>WHENEVER</strong> statement?</p>
<p><strong>A54.</strong> The <strong>WHENEVER</strong> statement is coded once in the host program  to control program actions depending on the SQL-CODE returned by each sql  statement within the program.</p>
<p><strong>Q55.</strong> What is <strong>DCLGEN</strong>?</p>
<p><strong>A55.</strong> <strong>DCLGEN</strong> stands for declarations generator; Ã‚Â it is a  facility to generate DB2 sql data structures in COBOL or PL/I programs.</p>
<p><strong>Q56.</strong> What is the <strong>FREE</strong> command?</p>
<p><strong>A56.</strong> The <strong>FREE</strong> command can be used to delete <strong>plans </strong>and/or <strong>packages</strong> no longer needed.</p>
<p><strong>Q57.</strong> DB2 can implement a join in three ways using a <strong>merge  join</strong>, a <strong>nested join</strong> or a <strong>hybrid join</strong>. Ã‚Â Explain the  differences.</p>
<p><strong>A57.</strong> A <strong>merge join </strong>requires that the tables being joined be in  a sequence; the rows are retrieved with a high cluster ratio index or are sorted  by DB2. Ã‚Â A <strong>nested join </strong>does not require a sequence and works best on  joining a small number of rows. DB2 reads the outer table values and each time  scans the inner table for matches. Ã‚Â The hybrid join is a nested join that  requires the outer table be in sequence.</p>
<p><strong>Q58.</strong> Compare a <strong>subselect </strong>to a <strong>join.</strong></p>
<p><strong>A58.</strong> Any subselect can be rewritten as a join, but not vice versa.  Ã‚Â Joins are usually more efficient as join rows can be returned immediately,  subselects require a temporary work area for inner selects results while  processing the outer select.</p>
<p><strong>Q59.</strong> What is the difference between <strong>IN subselects </strong>and  <strong>EXISTS</strong> subselect?</p>
<p><strong>A59.</strong> If there is an index on the attributes tested an IN is more  efficient since DB2 uses the index for the IN. Ã‚Â (IN for index is the mnemonic).</p>
<p><strong>Q60.</strong> What is a <strong>Cartesian product</strong>?</p>
<p><strong>A60.</strong> A <strong>Cartesian product </strong>results from a faulty query. Ã‚Â It is a  row in the results for every combination in the join tables.</p>
<p><strong>Q61.</strong> 4/99 Mail from <strong>Joseph Howard</strong>: Ã‚Â &#8217;<strong>Q:</strong> DB2 What is the  difference between a <strong>package</strong> and a <strong>plan</strong>? How does one bind 2  versions of a CICS transaction with the same module name in two different CICS  regions that share the same DB2 subsystem?</p>
<p><strong>A61.</strong> Package and plan are usually used synonomously, as in this site.  Both contain optimized code for SQL statements &#8211; a package for a single program,  module or subroutine contained in the datebase request module (<strong>DBRM</strong>)  library. A plan may contain multiple packages and pointers to packages. The one  CICS module would then exist in a package that could be referenced in two  different plans.</p>
<p><strong>Q62.</strong> What is an <strong>asychronous write</strong>?</p>
<p><strong>A62.</strong> It is a write to disk that may occur before or long after a  commit. Ã‚Â The write is controlled by the buffer manager.</p>
<p><strong>Q63.</strong> What is a <strong>lock</strong>?</p>
<p><strong>A63.</strong> A <strong>lock </strong>is the mechanism that controls access to data  pages and tablespaces.</p>
<p><strong>Q64.</strong> What is meant by <strong>isolation level</strong>?</p>
<p><strong>A64.</strong> This is a key concept for any relational database. Ã‚Â Isolation  level is the manner in which locks are applied and released during a  transaction. Ã‚Â For DB@ a &#8216;repeatable read&#8217; holds all locks untile the transaction  completes or a syncpoint is issued. Ã‚Â For transactions using &#8216;cursor stability&#8217;  the page lock releases are issued as the cursor &#8216;moves&#8217;, i.e. as the transaction  releases addressability to the records.</p>
<p><strong>Q65.</strong> What are <strong>leaf pages</strong>?</p>
<p><strong>A65.</strong> They are the opposite of <strong>root pages</strong>. Ã‚Â <strong>Leaf pages</strong> are the lowest level index pages &#8211; the pages that contain index entries and  information to the corresponding table rows.</p>
<p><strong>Q66.</strong> What is a <strong>precompiler</strong>?</p>
<p><strong>A66.</strong> It is a DB2 facility for static SQL statements &#8211; it replaces  these statements with calls to the DB2 language interface module.</p>
<p><strong>Q67.</strong> What is a <strong>root page</strong>?</p>
<p><strong>A67.</strong> The opposite of a <strong>leaf</strong> page; it is the highest level  index page. Ã‚Â An index can contain only the one root page; all other index pages  are associated to the root.</p>
<p><strong>Q68.</strong> What is a <strong>thread</strong>?</p>
<p><strong>A68.</strong> A <strong>thread</strong> is the connection between DB2 and some other  subsystem, such as CICS or IMS/DC.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Interview+Questions+DB2+%3A+Part+%E2%80%93+II+http%3A%2F%2Ftinyurl.com%2F3booonl" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Interview+Questions+DB2+%3A+Part+%E2%80%93+II+http%3A%2F%2Ftinyurl.com%2F3booonl" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=43&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; I'>Interview Questions DB2 : Part &#8211; I</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part Ã¢â‚¬â€œ II'>DB2 understanding : Part Ã¢â‚¬â€œ II</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-sql-codes-and-description.html' rel='bookmark' title='Permanent Link: DB2 : SQL Codes and Description'>DB2 : SQL Codes and Description</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interview Questions DB2 : Part &#8211; I</title>
		<link>http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html</link>
		<comments>http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html#comments</comments>
		<pubDate>Sat, 08 Aug 2009 17:34:25 +0000</pubDate>
		<dc:creator>neerajmehta1984</dc:creator>
				<category><![CDATA[Database Questions]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Mainframe]]></category>
		<category><![CDATA[DB2 interview questions asnwers]]></category>
		<category><![CDATA[IBM Main frame]]></category>
		<category><![CDATA[interview questions]]></category>

		<guid isPermaLink="false">http://www.interview.msdotnetheaven.com/?p=37</guid>
		<description><![CDATA[Interview Questions DB2 - Part - I


Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-sql-codes-and-description.html' rel='bookmark' title='Permanent Link: DB2 : SQL Codes and Description'>DB2 : SQL Codes and Description</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part Ã¢â‚¬â€œ II'>DB2 understanding : Part Ã¢â‚¬â€œ II</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong><span style="text-decoration: underline;"><span style="color: #3366ff;">The following is the entire collection of DB2 interview questions:</span></span></strong></p>
<p><strong><span style="color: #3366ff;"><strong><span style="color: #000000;">Q1. </span></strong><span style="color: #000000;">What is a DB2 </span><strong><span style="color: #000000;">bind</span></strong><span style="color: #000000;">?</span></span></strong></p>
<p><strong><span style="color: #3366ff;"><span style="color: #000000;"><strong>A1. </strong> A DB2 <strong>bind</strong> is a process that builds an access path to DB2  tables.</span></span></strong></p>
<p><strong>Q2</strong>. What is a DB2 <strong>access path</strong>?</p>
<p><strong>A2. </strong> An <strong>access path </strong>is the method used to access data specified  in DB2 sql statements.</p>
<p><strong>Q3. </strong>What is a DB2 <strong>plan</strong>?</p>
<p><strong>A3. </strong> An application plan or package is generated by the bind to define  an <strong>access path</strong>.</p>
<p><strong>Q4. </strong> What is <strong>normalization</strong> and what are the <strong>five normal  forms</strong>?</p>
<p><strong>A4. </strong> <strong>Normalization </strong>is a design procedure for representing data  in tabular format. Ã‚Â The five normal forms are progressive rules to represent the  data with minimal redundancy.</p>
<p><strong>Q5. </strong> What are <strong>foreign keys</strong>?</p>
<p><strong>A5. </strong>These are attributes of one table that have matching values in a  <strong>primary key</strong> in another table, allowing for relationships between tables.</p>
<p><strong>Q6. </strong> Describe the elements of the SELECT query syntax.</p>
<p><strong>A6. </strong> SELECT element FROM table WHERE conditional statement.</p>
<p><strong>Q7. </strong> Explain the use of the WHERE clause.</p>
<p><strong>A7. </strong> WHERE is used with a relational statement to isolate the object  element or row.</p>
<p><strong>Q8. </strong> What techniques are used to retrieve data from more than one  table in a single SQL statement?</p>
<p><strong>A8. </strong> <strong>Joins, unions </strong>and <strong>nested selects </strong>are used to  retrieve data.</p>
<p><strong>Q9. </strong> What do the initials DDL and DML stand for and what is their  meaning?</p>
<p><strong>A9. </strong> DDL is data definition language and DML is data manipulation  language. Ã‚Â DDL statements are CREATE, ALTER, TRUNCATE. Ã‚Â DML statements are  SELECT, INSERT, DELETE and UPDATE.</p>
<p><strong>Q10. </strong> What is a <strong>view</strong>? Why use it?</p>
<p><strong>A10.</strong> A view is a virtual table made up of data from base tables and  other views, but not stored separately.</p>
<p><strong>Q11.</strong> Explain an <strong>outer join</strong>.</p>
<p><strong>A11.</strong> An outer join includes rows from tables when there are no  matching values in the tables.</p>
<p><strong>Q12. </strong> What is a <strong>subselect</strong>? Ã‚Â Is it different from a <strong>nested  select</strong>?</p>
<p><strong>A12.</strong> A <strong>subselect </strong>is a select which works in conjunction with  another select. A <strong>nested select</strong> is a kind of subselect where the inner  select passes to the where criteria for the outer select.</p>
<p><strong>Q13. </strong> What is the difference between <strong>group by </strong>and <strong>order  by</strong>?</p>
<p><strong>A13.</strong> <strong>Group by</strong> controls the presentation of the rows, <strong>order  by</strong> controls the presentation of the columns Ã‚Â for the results of the SELECT  statement.</p>
<p><strong>Q14. </strong> <strong> </strong>Explain the EXPLAIN statement.</p>
<p><strong>A14.</strong> The explain statement provides information about the optimizer&#8217;s  choice of access path of the sql.</p>
<p><strong>Q15. </strong> <strong> </strong>What is <strong>tablespace</strong>?</p>
<p><strong>A15.</strong> Tables are stored in <strong>tablespaces </strong>(hence the name)! Ã‚Â There  are three types of tablespaces: simple, segmented and partitioned.</p>
<p><strong>Q16. </strong> What is <strong>a cursor </strong>and what is its function?</p>
<p><strong>A16.</strong> An embedded sql statement may return a number of rows while the  programming language can only access one row at a time. Ã‚Â The programming device  called a <strong>cursor </strong>controls the position of the row.</p>
<p><strong>Q17. </strong> What is <strong>referential integrity</strong>?</p>
<p><strong>A17.</strong> <strong>Referential integrity</strong> refers to the consistency that must  be maintained between primary and foreign keys, ie every <strong>foreign key </strong>value must have a corresponding <strong>primary key</strong> value.</p>
<p><strong>Q18. </strong>Usually, which is more important for DB2 system performance &#8211; CPU  processing or I/O access?</p>
<p><strong>A18.</strong> I/O operations are usually most critical for DB2 performance (or  any other database for that matter).</p>
<p><strong>Q19. </strong> Is there any advantage to <strong>denormalizing</strong> DB2 tables?</p>
<p><strong>A19.</strong> <strong>Denormalizing</strong> DB2 tables reduces the need for processing  intensive relational joins and reduces the number of foreign keys.</p>
<p><strong>Q20. </strong>What<strong> </strong>is the database descriptor?</p>
<p><strong>A20. </strong>The database descriptor, <strong>DBD </strong>is the DB2 component that  limits access to the database whenever objects are created, altered or dropped.</p>
<p><strong>Q21. </strong> What is <strong>lock contention</strong>?</p>
<p><strong>A21.</strong> To maintain the integrity of DB2 objects the DBD permits access  to only on object at a time. Ã‚Â <strong>Lock contention </strong>happens if several objects  are required by contending application processes simultaneously.</p>
<p><strong>Q22. </strong>What is<strong> SPUFI? </strong></p>
<p><strong>A22.</strong> <strong>SPUFI</strong> stands for SQL processing using file input. Ã‚Â It is  the DB2 interactive menu-driven tool used by developers to create database  objects.</p>
<p><strong>Q23. </strong>What is the significance of DB2 <strong>free space</strong> and what  parameters control it?</p>
<p><strong>A23.</strong> The two parameters Ã‚Â used in the CREATE statement are the  <strong>PCTFREE</strong> which specifies the percentage of free space for each page and  <strong>FREEPAGE </strong>which indicates the number of pages to be loaded with data  between each free page. Ã‚Â Free space allows room for the insertion of new rows.</p>
<p><strong>Q24. </strong> What is a <strong>NULL</strong> value? Ã‚Â What are the pros and cons of  using NULLS?</p>
<p><strong>A24.</strong> A <strong>NULL</strong> value takes up one byte of storage and indicates  that a value is not present as opposed to a space or zero value. Ã‚Â It&#8217;s the DB2  equivalent of TBD on an organizational chart and often correctly portrays a  business situation. Ã‚Â Unfortunately, it requires extra coding for an application  program to handle this situation.</p>
<p><strong>Q25. </strong> What is a <strong>synonym</strong>? Ã‚Â How is it used?</p>
<p><strong>A25.</strong> A <strong>synonym </strong>is used to reference a table or view by another  name. Ã‚Â The other name can then be written in the application code pointing to  test tables in the development stage and to production entities when the code is  migrated. Ã‚Â The synonym is linked to the AUTHID that created it.</p>
<p><strong>Q26. </strong> What is an <strong>alias </strong>and how does it differ from a  <strong>synonym</strong>?</p>
<p><strong>A26.</strong> An <strong>alias </strong>is an alternative to a <strong>synonym</strong>, designed  for a distributed environment to avoid having to use the location qualifier of a  table or view. Ã‚Â The alias is not dropped when the table is dropped.</p>
<p><strong>Q27. </strong> What is a LIKE table and how is it created?</p>
<p><strong>A27.</strong> A LIKE table is created by using the LIKE parameter in a CREATE  table statement. Ã‚Â LIKE tables are typically created for a test environment from  the production environment.</p>
<p><strong>Q28. </strong> If the base table underlying a view is restructured, eg.  attributes are added, does the application code accessing the view need to be  redone?</p>
<p><strong>A28.</strong> No. Ã‚Â The table and its view are created anew, but the programs  accessing the view do not need to be changed if the view and attributes accessed  remain the same.</p>
<p><strong>Q29. </strong> Under what circumstances will DB2 allow an SQL statement to  update more than one primary key value at a time?</p>
<p><strong>A29.</strong> Never. Ã‚Â Such processing could produce duplicate values  violating entity integrity.Ã‚Â Primary keys must be updated one at a time.</p>
<p><strong>Q30. </strong> What is the <strong>cascade rule</strong> and how does it relate to  deletions made with a subselect.</p>
<p><strong>A30.</strong> The <strong>cascade rule </strong>will not allow deletions based on a  subselect that references the same table from which the deletions are being  made.</p>
<p><strong>Q31. </strong> What is the <strong>self-referencing constraint</strong>?</p>
<p><strong>A31.</strong> The <strong>self-referencing</strong> constraint limits in a single table  the changes to a primary key that the related foreign key defines. Ã‚Â The foreign  key in a self referencing table must specify the DELETE CASCADE rule.</p>
<p><strong>Q32. </strong> What are <strong>delete-connected tables</strong>?</p>
<p><strong>A32.</strong> Tables related with a foreign key are called  <strong>delete-connected</strong> because a deletion in the primary key table can affect  the contents of the foreign key table.</p>
<p><strong>Q33. </strong>When can an insert of a new primary key value threaten  <strong>referential integrity</strong>?</p>
<p><strong>A33.</strong> Never. New primary key values are not a problem. Ã‚Â However, the  values of foreign key inserts must have corresponding primary key values in  their related tables. And updates of primary key values may require changes in  foreign key values to maintain <strong>referential integrity</strong>.</p>
<p><strong>Q34. </strong> In terms of DB2 indexing, what is the <strong>root page</strong>?</p>
<p><strong>A34.</strong> The simplest DB2 index is the <strong>B-tree</strong> and the B-tree&#8217;s top  page is called the <strong>root page</strong>. The root page entries represent the upper  range limits of the index and are referenced first in a search.</p>
<p><strong>Q35. </strong> How does Db2 use <strong>multiple table indexes</strong>?</p>
<p><strong>A35.</strong> DB2 use the <strong>multiple indexes</strong> to satisfy multiple  predicates in a SELECT statement that are joined by an AND or OR.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Interview+Questions+DB2+%3A+Part+%E2%80%93+I+http%3A%2F%2Ftinyurl.com%2F3uhztgb" title="Post to Twitter"><img class="nothumb" src="http://interview.msdotnetheaven.com/wp-content/plugins/tweet-this/icons/de/twitter/de/tt-twitter-micro4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Interview+Questions+DB2+%3A+Part+%E2%80%93+I+http%3A%2F%2Ftinyurl.com%2F3uhztgb" title="Post to Twitter">Tweet This Post</a></p></div><img src="http://interview.msdotnetheaven.com/?ak_action=api_record_view&id=37&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-ii.html' rel='bookmark' title='Permanent Link: Interview Questions DB2 : Part &#8211; II'>Interview Questions DB2 : Part &#8211; II</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-sql-codes-and-description.html' rel='bookmark' title='Permanent Link: DB2 : SQL Codes and Description'>DB2 : SQL Codes and Description</a></li>
<li><a href='http://interview.msdotnetheaven.com/database-question-answer/db2-understanding-part-ii.html' rel='bookmark' title='Permanent Link: DB2 understanding : Part Ã¢â‚¬â€œ II'>DB2 understanding : Part Ã¢â‚¬â€œ II</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://interview.msdotnetheaven.com/database-question-answer/interview-questions-db2-part-i.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

