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!

How to do Loop in a store procedure?

Status
Not open for further replies.

6656

Programmer
Nov 5, 2002
104
0
0
US
Hi all,

I'd like to have a loop in a stor procedure. It is simplar action like unix scrip.
i.e. for mystring in a b c d
do
print "$mystring is in mystring"
done

Someone can give me a example in SP?

Thanks in advance.
Mike
 
Hi,

Have you tried a while sentence in your SP?
i.e.
While @diff <= 0
begin
update....
...
if @diff < 0
...
else
select @diff = 1 => to exit loop
end

Hope this helps
 
Thanks inaranjo,

I am not sure how does @diff pass the charactor string (a b c...) in your sample given?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top