<?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; MsSql Server</title>
	<atom:link href="http://interview.msdotnetheaven.com/topics/database-question-answer/mssql-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>
	</channel>
</rss>

