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

Calling stored procedure multiple times from another stored proc 1

Status
Not open for further replies.

Angel123456789

Programmer
Dec 22, 2008
2
US
Guys,
Is it possible to call a stored procedure from another stored procedure multiple times without using a cursor...
Alter sp_main
Select name month, year from table1
where month>=@begmonth and month=<@endmonth

/* say beg month is 4 and end month is 5 the i should call
the below stored proc there times first when month=3 then month=4 and then month =5*/
exec caldetails @name,@month
Is its possible to do the above without using cursors
Any help appreciated.
thanks
 
You can use looping logic in T-SQL. Here's an example:

Code:
DECLARE @Start INT
DECLARE @End INT
SELECT @Start = 1
SELECT @End = 5
WHILE @Start <= @End
BEGIN
  --Do Something
  SELECT @Start = @Start + 1
END

Just apply that logic to your particular case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top