Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 For Loops? Do they exist in SQL Server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-24 : 10:46:22
John writes "I have used For Loops in Oracle in the past similar to this syntax:

for x in 1..v_example loop
/*CODE HERE*/
end loop;

I couldn't find any documentation for this in SQL Server. If it exists, could I see an example? Thanks much in advance.
-JOhn"

monkeybite
Posting Yak Master

152 Posts

Posted - 2002-04-24 : 10:56:15
There's no FOR statement in TSQL for Control-of-flow. There is a WHILE loop that can perform the same task.

Ex:

DECLARE @i int
SELECT @i = 1

WHILE @i < 10
BEGIN
SELECT @i
SELECT @i = @i + 1
END



For more about WHILE and other control-of-flow statements, consult SQL Books Online, or view it online here:

[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_con_04_66yf.asp[/url]

-- monkey
Go to Top of Page
   

- Advertisement -