<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Simple Example of WHILE Loop With CONTINUE and BREAK Keywords</title>
	<atom:link href="http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: sathish</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-461347</link>
		<dc:creator><![CDATA[sathish]]></dc:creator>
		<pubDate>Mon, 22 Apr 2013 11:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-461347</guid>
		<description><![CDATA[Hai friend 
      In the above code is there one mistake that is @j=@i*@j it is not possible that  at that place you have to put the @j=@i*1 .....................ok]]></description>
		<content:encoded><![CDATA[<p>Hai friend<br />
      In the above code is there one mistake that is @j=@i*@j it is not possible that  at that place you have to put the @j=@i*1 &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;ok</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vinay</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-445731</link>
		<dc:creator><![CDATA[vinay]]></dc:creator>
		<pubDate>Thu, 28 Mar 2013 04:31:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-445731</guid>
		<description><![CDATA[In the 3rd line ur trying to print @j but no value is assigned to @j .. 1st assign the value and print]]></description>
		<content:encoded><![CDATA[<p>In the 3rd line ur trying to print @j but no value is assigned to @j .. 1st assign the value and print</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arunraja (Rocket)</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-417119</link>
		<dc:creator><![CDATA[Arunraja (Rocket)]]></dc:creator>
		<pubDate>Sun, 03 Feb 2013 10:28:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-417119</guid>
		<description><![CDATA[Hi Pinal,
Hope you are doing good.

The looping query pasted below works fine in updating &#039;hour&#039; in a date time column using NTILE().

+++++++++++++++++++
 DECLARE @loop int
  DECLARE @inc int
  
  SET @inc=1  
  WHILE (@inc&lt;=24)
  
  BEGIN
  
    ;with up AS
    (
    SELECT salesorderdetailid,ntile(24) OVER (order by productid ) as ntile24
    from sales.salesorderdetail
    )
    UPDATE sales.salesorderdetail
    SET modifieddate=DATEADD(hh,@inc,modifieddate)
    from sales.salesorderdetail
    where salesorderdetailid in
    (
		select salesorderdetailid from up   
		where NTILe24 =@inc
    )
  PRINT @inc
  SET @inc=@inc+1
  END
  
  
  --select * from sales.salesorderdetail tablesample (1000 rows)

+++++++++++++++++++

Is there any simplest way to solve this problem? 
OR
If the query can be modified without using CTE?

Kindly suggest how to increase the query performance when handling these situations.

Thanks,
Arunraja.]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
Hope you are doing good.</p>
<p>The looping query pasted below works fine in updating &#8216;hour&#8217; in a date time column using NTILE().</p>
<p>+++++++++++++++++++<br />
 DECLARE @loop int<br />
  DECLARE @inc int</p>
<p>  SET @inc=1<br />
  WHILE (@inc&lt;=24)</p>
<p>  BEGIN</p>
<p>    ;with up AS<br />
    (<br />
    SELECT salesorderdetailid,ntile(24) OVER (order by productid ) as ntile24<br />
    from sales.salesorderdetail<br />
    )<br />
    UPDATE sales.salesorderdetail<br />
    SET modifieddate=DATEADD(hh,@inc,modifieddate)<br />
    from sales.salesorderdetail<br />
    where salesorderdetailid in<br />
    (<br />
		select salesorderdetailid from up<br />
		where NTILe24 =@inc<br />
    )<br />
  PRINT @inc<br />
  SET @inc=@inc+1<br />
  END</p>
<p>  &#8211;select * from sales.salesorderdetail tablesample (1000 rows)</p>
<p>+++++++++++++++++++</p>
<p>Is there any simplest way to solve this problem?<br />
OR<br />
If the query can be modified without using CTE?</p>
<p>Kindly suggest how to increase the query performance when handling these situations.</p>
<p>Thanks,<br />
Arunraja.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: faisal sadique</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-379993</link>
		<dc:creator><![CDATA[faisal sadique]]></dc:creator>
		<pubDate>Sat, 24 Nov 2012 12:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-379993</guid>
		<description><![CDATA[welcome]]></description>
		<content:encoded><![CDATA[<p>welcome</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: faisal sadique</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-379990</link>
		<dc:creator><![CDATA[faisal sadique]]></dc:creator>
		<pubDate>Sat, 24 Nov 2012 12:48:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-379990</guid>
		<description><![CDATA[no i cant help u]]></description>
		<content:encoded><![CDATA[<p>no i cant help u</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sujitha</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-371880</link>
		<dc:creator><![CDATA[sujitha]]></dc:creator>
		<pubDate>Sat, 10 Nov 2012 00:00:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-371880</guid>
		<description><![CDATA[Hello sir,
I need help from you
i have two columns 
let me give example
masterid           attributename         attributevalue
-------------         --------------------        -----------------
1                           mode_code               barge
1                            sap_code                   B
1                               Description              g

here i know how many attribute names are there so i can use cases here to update.

UPDATE CORE.MasterAttr
SET AttributeValue = (
    CASE AttributeName
        WHEN &#039;DESCRIPTION&#039; THEN &#039;Barge&#039;
        WHEN &#039;SAP_MODE&#039; THEN &#039;01&#039;
        WHEN &#039;MODE_CODE&#039; THEN &#039;B&#039;        
    END
) WHERE MasterId=1


but in real scenario i dont know how many attribute name will be available.
so i need to write storedprocedure .the input values will come from c#.
suppose for master id 2 i can have 12 attribute names and i have to update attribute vales for those attribute names.
if we give give masterid 4 and we can get 15 attribute names etc.

so how can we dynamically loop it and write stored procedure sir.it will really helps me alot.can u please help me on this.]]></description>
		<content:encoded><![CDATA[<p>Hello sir,<br />
I need help from you<br />
i have two columns<br />
let me give example<br />
masterid           attributename         attributevalue<br />
&#8212;&#8212;&#8212;&#8212;-         &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;        &#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
1                           mode_code               barge<br />
1                            sap_code                   B<br />
1                               Description              g</p>
<p>here i know how many attribute names are there so i can use cases here to update.</p>
<p>UPDATE CORE.MasterAttr<br />
SET AttributeValue = (<br />
    CASE AttributeName<br />
        WHEN &#8216;DESCRIPTION&#8217; THEN &#8216;Barge&#8217;<br />
        WHEN &#8216;SAP_MODE&#8217; THEN &#8217;01&#8242;<br />
        WHEN &#8216;MODE_CODE&#8217; THEN &#8216;B&#8217;<br />
    END<br />
) WHERE MasterId=1</p>
<p>but in real scenario i dont know how many attribute name will be available.<br />
so i need to write storedprocedure .the input values will come from c#.<br />
suppose for master id 2 i can have 12 attribute names and i have to update attribute vales for those attribute names.<br />
if we give give masterid 4 and we can get 15 attribute names etc.</p>
<p>so how can we dynamically loop it and write stored procedure sir.it will really helps me alot.can u please help me on this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: latha</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-363287</link>
		<dc:creator><![CDATA[latha]]></dc:creator>
		<pubDate>Tue, 23 Oct 2012 09:58:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-363287</guid>
		<description><![CDATA[Hi i have one city table. in that i have to calculate the distance url  between those cities. for example i have 5 city names like chennai,hyderabad,kolkuta, delhi, and mumbai. in that i have to calculate distance url like chennai to hyderabad, chennai to kokata, chennai to delhi, chennai to mumbai. i have query for single city but we have many cities in that table. i want to run the query for all cities in single query please help me....]]></description>
		<content:encoded><![CDATA[<p>Hi i have one city table. in that i have to calculate the distance url  between those cities. for example i have 5 city names like chennai,hyderabad,kolkuta, delhi, and mumbai. in that i have to calculate distance url like chennai to hyderabad, chennai to kokata, chennai to delhi, chennai to mumbai. i have query for single city but we have many cities in that table. i want to run the query for all cities in single query please help me&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: B. Shunmuga Sundari</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-361433</link>
		<dc:creator><![CDATA[B. Shunmuga Sundari]]></dc:creator>
		<pubDate>Thu, 18 Oct 2012 07:09:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-361433</guid>
		<description><![CDATA[hi i am shunmuga sundari,
          i have one doubt that &quot; is it possible execute a &#039;insert into&#039; query into the while or for loop?&quot;]]></description>
		<content:encoded><![CDATA[<p>hi i am shunmuga sundari,<br />
          i have one doubt that &#8221; is it possible execute a &#8216;insert into&#8217; query into the while or for loop?&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akshobhya</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-342779</link>
		<dc:creator><![CDATA[Akshobhya]]></dc:creator>
		<pubDate>Tue, 11 Sep 2012 09:08:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-342779</guid>
		<description><![CDATA[declare @i int
declare @n int
set @i=0
set @n=10
while(@i&lt;=@n)
BEGIN
PRINT &#039;A&#039;
set @i=@i+1
END

i have doubt when i use the variables i and n as integer type ,A is printed 11
times 
declare @i varchar(10)
declare @n varchar(10)
set @i=0
set @n=10
while(@i&lt;=@n)
BEGIN
PRINT &#039;A&#039;
set @i=@i+1
END

when i use the variables i and n as varchar ,A is printed twice can you please tell me the reason y this could be like this]]></description>
		<content:encoded><![CDATA[<p>declare @i int<br />
declare @n int<br />
set @i=0<br />
set @n=10<br />
while(@i&lt;=@n)<br />
BEGIN<br />
PRINT &#039;A&#039;<br />
set @i=@i+1<br />
END</p>
<p>i have doubt when i use the variables i and n as integer type ,A is printed 11<br />
times<br />
declare @i varchar(10)<br />
declare @n varchar(10)<br />
set @i=0<br />
set @n=10<br />
while(@i&lt;=@n)<br />
BEGIN<br />
PRINT &#039;A&#039;<br />
set @i=@i+1<br />
END</p>
<p>when i use the variables i and n as varchar ,A is printed twice can you please tell me the reason y this could be like this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: subash</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-327065</link>
		<dc:creator><![CDATA[subash]]></dc:creator>
		<pubDate>Wed, 08 Aug 2012 11:14:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-327065</guid>
		<description><![CDATA[hi i have a string like 
HHHHHHsuhhhsusu each character represents a date starting from 28/07/2012  and im trying to select it or create a table 
create table #calender (string as char(5)COLLATE SQL_Latin1_General_CP1_CI_AS, dat datetime)
declare @counter as int 
set @counter = 3
while (@counter &lt; 367)
begin 
--print @counter


--insert into #calender (string,dat)
 select distinct substring  (CCAL_Available_Days
,@counter,1), dateadd (day,@counter,&#039;2012-07-28 00:00:00.000&#039;) date from dbo.CCALCalend
where CCAL_Year = &#039;2012&#039;
set @counter = @counter+1
--select * from #calender

end 
 drop table #calender
 i am getting the error 
The column &quot;string&quot; cannot be modified because it is either a computed column or is the result of a UNION operator.
can you please help]]></description>
		<content:encoded><![CDATA[<p>hi i have a string like<br />
HHHHHHsuhhhsusu each character represents a date starting from 28/07/2012  and im trying to select it or create a table<br />
create table #calender (string as char(5)COLLATE SQL_Latin1_General_CP1_CI_AS, dat datetime)<br />
declare @counter as int<br />
set @counter = 3<br />
while (@counter &lt; 367)<br />
begin<br />
&#8211;print @counter</p>
<p>&#8211;insert into #calender (string,dat)<br />
 select distinct substring  (CCAL_Available_Days<br />
,@counter,1), dateadd (day,@counter,&#039;2012-07-28 00:00:00.000&#039;) date from dbo.CCALCalend<br />
where CCAL_Year = &#039;2012&#039;<br />
set @counter = @counter+1<br />
&#8211;select * from #calender</p>
<p>end<br />
 drop table #calender<br />
 i am getting the error<br />
The column &quot;string&quot; cannot be modified because it is either a computed column or is the result of a UNION operator.<br />
can you please help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krishna</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-322193</link>
		<dc:creator><![CDATA[Krishna]]></dc:creator>
		<pubDate>Tue, 31 Jul 2012 05:01:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-322193</guid>
		<description><![CDATA[Can we replace column values of a table with a series of values using While statement?]]></description>
		<content:encoded><![CDATA[<p>Can we replace column values of a table with a series of values using While statement?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: karthick</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-321838</link>
		<dc:creator><![CDATA[karthick]]></dc:creator>
		<pubDate>Mon, 30 Jul 2012 13:05:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-321838</guid>
		<description><![CDATA[how to use vb function to sql query function

ex:
function emp()

str=”select * from employ”
set rs=conn.execute(str)

do while rs.eof=false

for i= 1 to 6

if sex=’m’ then

update status=’male’ where empcode=&quot; &amp; rs!emocode &amp; &quot;

else

update status=’female’ where empcode=&quot; &amp; rs!emocode &amp; &quot;

next

loop

end function]]></description>
		<content:encoded><![CDATA[<p>how to use vb function to sql query function</p>
<p>ex:<br />
function emp()</p>
<p>str=”select * from employ”<br />
set rs=conn.execute(str)</p>
<p>do while rs.eof=false</p>
<p>for i= 1 to 6</p>
<p>if sex=’m’ then</p>
<p>update status=’male’ where empcode=&#8221; &amp; rs!emocode &amp; &#8221;</p>
<p>else</p>
<p>update status=’female’ where empcode=&#8221; &amp; rs!emocode &amp; &#8221;</p>
<p>next</p>
<p>loop</p>
<p>end function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karan Patel</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-313072</link>
		<dc:creator><![CDATA[Karan Patel]]></dc:creator>
		<pubDate>Fri, 13 Jul 2012 16:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-313072</guid>
		<description><![CDATA[The best way is use a cursor:

example To Delete All Products

and if 1 product record has dependencies

For each Product record, there is a record also in Product Inventory table


DECLARE 
cursor c1 is
      SELECT 
       ID AS i_PRODUCTID, 
FROM PRODUCT 
ORDER BY ID ASC;

BEGIN
FOR DELETEPRODUCTRECORD in c1
LOOP
		DELETE FROM PRODUCT_INVENTORY WHERE PRODUCTID = DELETEPRODUCTRECORD .i_PRODUCTID;

DELETE FROM PRODUCT WHERE ID = DELETEPRODUCTRECORD .i_PRODUCTID;

END LOOP;

END;

==

In terms of performance and simplicity, this is the best method i have seen]]></description>
		<content:encoded><![CDATA[<p>The best way is use a cursor:</p>
<p>example To Delete All Products</p>
<p>and if 1 product record has dependencies</p>
<p>For each Product record, there is a record also in Product Inventory table</p>
<p>DECLARE<br />
cursor c1 is<br />
      SELECT<br />
       ID AS i_PRODUCTID,<br />
FROM PRODUCT<br />
ORDER BY ID ASC;</p>
<p>BEGIN<br />
FOR DELETEPRODUCTRECORD in c1<br />
LOOP<br />
		DELETE FROM PRODUCT_INVENTORY WHERE PRODUCTID = DELETEPRODUCTRECORD .i_PRODUCTID;</p>
<p>DELETE FROM PRODUCT WHERE ID = DELETEPRODUCTRECORD .i_PRODUCTID;</p>
<p>END LOOP;</p>
<p>END;</p>
<p>==</p>
<p>In terms of performance and simplicity, this is the best method i have seen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JFCruzS</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-306573</link>
		<dc:creator><![CDATA[JFCruzS]]></dc:creator>
		<pubDate>Wed, 27 Jun 2012 17:20:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-306573</guid>
		<description><![CDATA[Genial !! muchas gracias.]]></description>
		<content:encoded><![CDATA[<p>Genial !! muchas gracias.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Creatives Sys</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-301644</link>
		<dc:creator><![CDATA[Creatives Sys]]></dc:creator>
		<pubDate>Fri, 15 Jun 2012 11:44:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-301644</guid>
		<description><![CDATA[Nice way]]></description>
		<content:encoded><![CDATA[<p>Nice way</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EnMa Ursula</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-293924</link>
		<dc:creator><![CDATA[EnMa Ursula]]></dc:creator>
		<pubDate>Mon, 04 Jun 2012 17:55:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-293924</guid>
		<description><![CDATA[Great Examples!
I would love to share this on my blog.
Please let me know if you would like to keep this posting content within your blog only.

Thank you

Enma]]></description>
		<content:encoded><![CDATA[<p>Great Examples!<br />
I would love to share this on my blog.<br />
Please let me know if you would like to keep this posting content within your blog only.</p>
<p>Thank you</p>
<p>Enma</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael n Madonna</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-283935</link>
		<dc:creator><![CDATA[Michael n Madonna]]></dc:creator>
		<pubDate>Fri, 11 May 2012 17:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-283935</guid>
		<description><![CDATA[you just copy all your sample in msdn you - oink oink.]]></description>
		<content:encoded><![CDATA[<p>you just copy all your sample in msdn you &#8211; oink oink.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rfer</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-282952</link>
		<dc:creator><![CDATA[rfer]]></dc:creator>
		<pubDate>Tue, 08 May 2012 13:54:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-282952</guid>
		<description><![CDATA[try using UNION function with above query and other query which will give only start date]]></description>
		<content:encoded><![CDATA[<p>try using UNION function with above query and other query which will give only start date</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pooja</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-281313</link>
		<dc:creator><![CDATA[Pooja]]></dc:creator>
		<pubDate>Wed, 02 May 2012 06:15:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-281313</guid>
		<description><![CDATA[Hi everyone,
     I have a table which holds data regarding &#039;TicketNo&#039;,its &#039;Mkrdt&#039;,&#039;Loginid&#039;,&#039;Mkrid&#039; etc.. I want to list the &#039;Startdate&#039; of each ticket , coz each ticket processing is done many days , and i want to also list &#039;Days Taken&#039; for processing that ticket no.. I had a solution, but i get parcial results..I WANT TO LIST STATDATE N DATSTAKEN IN FRONT OF EACH ENTRY OF A PERTICULAR TICKET. .. I had a query related to this as ..


SELECT a.ticketno, a.mkrdt
     FROM Tbl_Newtagg1 a, (SELECT TicketNo, min(mkrdt) AS StartDate FROM Tbl_Newtagg1 GROUP BY TicketNo) b
     WHERE a.TicketNo = b.TicketNo AND a.mkrdt =b.startdate

--but it lists every ticket n its startdate only once.. plz help.. Thanks in advance]]></description>
		<content:encoded><![CDATA[<p>Hi everyone,<br />
     I have a table which holds data regarding &#8216;TicketNo&#8217;,its &#8216;Mkrdt&#8217;,'Loginid&#8217;,'Mkrid&#8217; etc.. I want to list the &#8216;Startdate&#8217; of each ticket , coz each ticket processing is done many days , and i want to also list &#8216;Days Taken&#8217; for processing that ticket no.. I had a solution, but i get parcial results..I WANT TO LIST STATDATE N DATSTAKEN IN FRONT OF EACH ENTRY OF A PERTICULAR TICKET. .. I had a query related to this as ..</p>
<p>SELECT a.ticketno, a.mkrdt<br />
     FROM Tbl_Newtagg1 a, (SELECT TicketNo, min(mkrdt) AS StartDate FROM Tbl_Newtagg1 GROUP BY TicketNo) b<br />
     WHERE a.TicketNo = b.TicketNo AND a.mkrdt =b.startdate</p>
<p>&#8211;but it lists every ticket n its startdate only once.. plz help.. Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: philip</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-268706</link>
		<dc:creator><![CDATA[philip]]></dc:creator>
		<pubDate>Wed, 28 Mar 2012 04:15:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-268706</guid>
		<description><![CDATA[hi i am really stuck in my assingnment......can u help me please?]]></description>
		<content:encoded><![CDATA[<p>hi i am really stuck in my assingnment&#8230;&#8230;can u help me please?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maddy</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-268262</link>
		<dc:creator><![CDATA[Maddy]]></dc:creator>
		<pubDate>Tue, 27 Mar 2012 09:10:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-268262</guid>
		<description><![CDATA[I have one query below is the details,

Tab:

col1 Key  col2   startdate      enddate
1     10    100   20111215     29991231
1     10    100   20111220     20111225
1     10    100   20111215     29991231
1     10    100   20111215     29991231



I want output as 

col1 Key  col2   startdate      enddate
1     10    100   20111215     20111219
1     10    100   20111220     20111225
1     10    100   20111215     20111224
1     10    100   20111225     29991231

i think need to write a loop which will update the endate properly.

Please help...]]></description>
		<content:encoded><![CDATA[<p>I have one query below is the details,</p>
<p>Tab:</p>
<p>col1 Key  col2   startdate      enddate<br />
1     10    100   20111215     29991231<br />
1     10    100   20111220     20111225<br />
1     10    100   20111215     29991231<br />
1     10    100   20111215     29991231</p>
<p>I want output as </p>
<p>col1 Key  col2   startdate      enddate<br />
1     10    100   20111215     20111219<br />
1     10    100   20111220     20111225<br />
1     10    100   20111215     20111224<br />
1     10    100   20111225     29991231</p>
<p>i think need to write a loop which will update the endate properly.</p>
<p>Please help&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: birla</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-265601</link>
		<dc:creator><![CDATA[birla]]></dc:creator>
		<pubDate>Wed, 21 Mar 2012 09:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-265601</guid>
		<description><![CDATA[i want program in for..loop ..give some example]]></description>
		<content:encoded><![CDATA[<p>i want program in for..loop ..give some example</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikhilesh Patidar</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-256153</link>
		<dc:creator><![CDATA[Nikhilesh Patidar]]></dc:creator>
		<pubDate>Fri, 24 Feb 2012 08:17:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-256153</guid>
		<description><![CDATA[--Select name FROM sys.databases order by name

--Create DataBase And Drop Database
declare @i int
declare @sSQL nvarchar(50)
--Create DataBase
set @i=1
while (@i&lt;=10)
begin
	print @i
	set @sSQL=&#039;Create database abc&#039;+ cast(@i as nvarchar(50))
	 EXEC(@sSQL)
	set @i=@i+1
end
--Drop DataBase
set @i=1
while (@i&lt;=10)
begin
	print @i
	set @sSQL=&#039;Drop database abc&#039;+ cast(@i as nvarchar(50))
	 EXEC(@sSQL)
	set @i=@i+1
end]]></description>
		<content:encoded><![CDATA[<p>&#8211;Select name FROM sys.databases order by name</p>
<p>&#8211;Create DataBase And Drop Database<br />
declare @i int<br />
declare @sSQL nvarchar(50)<br />
&#8211;Create DataBase<br />
set @i=1<br />
while (@i&lt;=10)<br />
begin<br />
	print @i<br />
	set @sSQL=&#039;Create database abc&#039;+ cast(@i as nvarchar(50))<br />
	 EXEC(@sSQL)<br />
	set @i=@i+1<br />
end<br />
&#8211;Drop DataBase<br />
set @i=1<br />
while (@i&lt;=10)<br />
begin<br />
	print @i<br />
	set @sSQL=&#039;Drop database abc&#039;+ cast(@i as nvarchar(50))<br />
	 EXEC(@sSQL)<br />
	set @i=@i+1<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Regenesis</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-254943</link>
		<dc:creator><![CDATA[Regenesis]]></dc:creator>
		<pubDate>Tue, 21 Feb 2012 19:03:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-254943</guid>
		<description><![CDATA[thank you very much, you save me live.]]></description>
		<content:encoded><![CDATA[<p>thank you very much, you save me live.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahmoud Shahin</title>
		<link>http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-223433</link>
		<dc:creator><![CDATA[Mahmoud Shahin]]></dc:creator>
		<pubDate>Thu, 22 Dec 2011 05:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/10/24/sql-server-simple-example-of-while-loop-with-continue-and-break-keywords/#comment-223433</guid>
		<description><![CDATA[thank  you  very  much]]></description>
		<content:encoded><![CDATA[<p>thank  you  very  much</p>
]]></content:encoded>
	</item>
</channel>
</rss>
