?
Solved

How to create LOOP STRUCTURE in a stored procedure in SQL Server ?

Posted on 2001-09-05
7
Medium Priority
?
541 Views
Last Modified: 2008-02-01
Hi,
Can anybody suggest me for , how to create LOOP STRUCTURE in a stored procedure in SQL Server? Pl give me example.

Thanx a lot
waiting for reply.
From
Santosh
0
Comment
Question by:SantoshGokhale
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6456319
one way is using bookmarks:

 declare @var int
 set @var = 0

LOOP:
  select @var = @var + 1

  -- some code here...

  if @var < 10 GOTO LOOP


Cheers

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6457130
If you would rather not use GoTo's than the While loop is what you are looking for:

@I = 1
While @I <= 10
   Begin
      ...
      @I = @I + 1
   End

0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
ID: 6457641
That should have been:
Set @I = 1
While @I <= 10
  Begin
     ...
     Set @I = @I + 1
  End

Anthony
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:prakashbitra
ID: 6458233
can u explain me ur  requirement
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6462925
prakashbitra,

I think the chances that SantoshGokhale will followup are pretty remote, considering his past grading history:

Questions Asked 4
Last 10 Grades Given  
Question Grading Record 0 Answers Graded / 0 Answers Received

All the other questions are from July.

Anthony
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7207643
Hi SantoshGokhale@devx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Split points between: angelIII and acperkins@devx

SantoshGokhale@devx, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7240973
Per recommendation, force-accepted.

Netminder
CS Moderator

angel111: points for you at http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20341024.html
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question