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

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

Posted on 2001-09-05
Last Modified: 2008-02-01
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.
Question by:SantoshGokhale
LVL 143

Expert Comment

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

 declare @var int
 set @var = 0

  select @var = @var + 1

  -- some code here...

  if @var < 10 GOTO LOOP


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
      @I = @I + 1

LVL 75

Accepted Solution

Anthony Perkins earned 25 total points
ID: 6457641
That should have been:
Set @I = 1
While @I <= 10
     Set @I = @I + 1

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Expert Comment

ID: 6458233
can u explain me ur  requirement
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6462925

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.

LVL 49

Expert Comment

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

Expert Comment

ID: 7240973
Per recommendation, force-accepted.

CS Moderator

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 / DAO 3.6 / run time error: Couldn't find installable ISAM 7 102
Add a task in Outlook from access 11 42
MsgBox 4 68
how to Classify of email (pdf attachments) 7 45
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

808 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