Monday, September 16, 2013

SQL WHILE LOOP Example

Here i describe how to use while loop in SQL  Server
 

declare @datefrom datetime,
@dateto datetime ,
@Datevar datetime
select @datefrom=MIN(ActiveDate),@dateto=MAX(ActiveDate) from #tmpClients


set @Datevar=@datefrom
while @Datevar<=@dateto
Begin

//--Code here ---
select @Datevar

SET @Datevar =   dateAdd(dd,+1,@Datevar)
end

If you are searching life partner. your searching end with kpmarriage.com. now kpmarriage.com offer free matrimonial website which offer free message, free chat, free view contact information. so register here : kpmarriage.com- Free matrimonial website

Related Posts:

  • HAVING clause HAVING clause The HAVING clause allows you to specify conditions on the rows for each group - in other wo… Read More
  • ORDER BY clause ORDER BY clause ORDER BY is an optional clause which will allow you to display the results of your query in a sorted order (ei… Read More
  • SQL INNER JOIN Keyword SQL INNER JOIN Keyword The INNER JOIN keyword returns rows when there is at least one match in both tables. SQL INNER JOIN Syntax SELECT column_n… Read More
  • SQL JOIN table.reference tr.fixzebra { background-color: #F6F4F0; } table.reference th { background-color: #555555; border: 1px solid #555555; … Read More
  • sql_in_between_operatos IN & BETWEEN IN operator Syntax : SELECT col1, SUM(col2) FROM "list-of-tables" WHERE col3 IN … Read More

0 comments:

Post a Comment