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:

  • SQL SELECT DISTINCT StatementIn a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (dist… Read More
  • Database TablesA database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) wi… Read More
  • SQL DML and DDLSQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). The query and update commands form th… Read More
  • Using SQL in Your Web SiteTo build a web site that shows some data from a database, you will need the following: * An RDBMS database program (i.e. MS Access, SQL Server, M… Read More
  • SQL SELECT StatementSELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. SQL SELECT Syntax SELECT col… Read More

0 comments:

Post a Comment