Solved

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

Posted on 2001-09-05
7
534 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
7 Comments
 
LVL 142

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 25 total points
ID: 6457641
That should have been:
Set @I = 1
While @I <= 10
  Begin
     ...
     Set @I = @I + 1
  End

Anthony
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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