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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a simple loop

Status
Not open for further replies.

vorvad

Technical User
Nov 21, 2001
9
0
0
US
Can someone help me with the syntax for creating a simple loop.

I want to do the following:

Start with a number (lets say 5), then I want to multiply this value by a simple calculation (i.e. (5 * 3.14) / 10 = 1.8055).
I then want to take this new number, and apply it to the same calculation (i.e. 1.8055 * 3.14 / 10 = .5669), etc...

I also need to tell it when to stop the loop.
Thanks in advance!
VB
 
A basic looping structures in many programming langauges, including SQL is the While loop.

Declare @calc decimal(18,12), @cnt int
Select @calc=5, @cnt=0

While @cnt<6
Begin
Select @calc=@calc * 3.14 / 10, @cnt=@cnt+1
End

Select Result=@calc Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top