The WHILE loop iterates while the expression evaluates to TRUE.With the WHILE loop you can either increment a variable or make use of a table cursor.
Syntax with table cursor:WHILE table.EOF=false PRINT 'We just read the column and got the value 'table.Column_name_in_tableMOVENEXT tableLOOP Syntax with variable:WHILE @variable<max_valuePRINT 'Variable is now '@variableSET @variable=@variable+increment_valueLOOP
Iterating a value until condition is reached.
DECLARE @Company varchar
/* Create the internal table SalesCompanies in the InMemory data store */IMPORT SalesCompanies=me.{SELECT 'Denmark' AS TablePrefix UNION ALL SELECT 'United States'}
/* While Loop for each company in the SalesCompanies (Denmark/United States) (see above) */WHILE SalesCompanies.EOF=false
/* Set up the variable company */SET @Company=SalesCompanies.TablePrefix
/* Read the data from the SQL server connection from the table substituting part of the tablename - SQL becomes e.g. SELECT from Denmark_Sales /IMPORT factSalesData=sqldb.{SELECT * FROM @@COMPANY_Sales} MOVENEXT SalesCompanies / Move cursor to the next CompanyLOOP / Iterate the loop */DECLARE @i as int
SET @i=1
WHILE @i<=10 PRINT @i SET @i=@i+1LOOP