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