Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For-Next Loop Query. Pls. Help

Status
Not open for further replies.

aspengal

Technical User
Dec 27, 2004
41
0
0
US
Can anyone tell me the syntax for the For-Next loop if at all any in SQL server PL/SQL?

Thanks
 
No direct equivalent. Looping is either done through using WHILE or Cursors, the latter of which you are advised to stay away from.

If you give a more specific example of what it is you are looking to do, you might get someone to post the best way of doing it, if SQL is the right place to do it in.

"I'm living so far beyond my income that we may almost be said to be living apart
 
You can do the equivalent.

@X=0
While X < 100
Begin
@X = @X + 1
etc.

Cursors are more complicated but very handy
 

The comment on cursors - As a regular reader of the forum and occasional contributor, I think it should be noted that most people would advise against Cursors even though they are "very handy".
They are extremely poor from a performance aspect and can cause more headaches than benefits.
Yes they provide a handy way of looping, but in most instances you should be able to use set based processing, and in the FAQs there are some examples on how to do this.



"I'm living so far beyond my income that we may almost be said to be living apart
 
SQL Server doesn't use PL/SQL. ORACLE uses PL/SQL.

I suggest posting your question in an Oracle forum. Unless of course, you really meant TSQL, which is what Microsoft SQL Server uses and what this forum is for.

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top