calling a stored procedure in a while loop
- From: Vic <vikrantp@xxxxxxxxx>
- Date: Fri, 22 Feb 2008 17:14:12 -0800 (PST)
I am trying to call a stored procedure in a while loop but for some
reason it only returns 1 row whereas I am expectint 12 rows
Here is the stored procedure and the call
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER procedure [dbo].[SP_FETCH_ROWS](@num int)
AS
SELECT Table_Name from TestData6061.INFORMATION_SCHEMA.Tables a where
@num =(select count(*) from TestData6061.INFORMATION_SCHEMA.Tables b
where a.Table_Name >= b.Table_Name)
go
While Loop which calls the stored procedure and passing the loop
counter as the argument
DECLARE @Count int DECLARE @MaxCount int
SET @Count = 0
SET @MaxCount = 29 WHILE @Count < @MaxCount BEGIN
SET @Count = @Count + 1 IF @Count = 1 OR
@Count = 4 OR
@Count = 7 OR
@Count = 8 OR
@Count = 14 OR
@Count = 17 OR
@Count = 18 OR
@Count = 22 OR
@Count = 25 OR
@Count = 27 OR
@Count = 28 OR
@Count = 29 EXEC releases.dbo.SP_FETCH_ROWS
@Count END
what am I missing here? I tried to figure out n looked for all kinds
of online documentation but still couldn't find the solution. please
helop
.
- Follow-Ups:
- Re: calling a stored procedure in a while loop
- From: Plamen Ratchev
- Re: calling a stored procedure in a while loop
- Prev by Date: Re: sql query which has got 3 dynamic parameters
- Next by Date: DB size increase from SQL 2000 to 2005
- Previous by thread: Re: Use unique key for Sqlserver view for updates
- Next by thread: Re: calling a stored procedure in a while loop
- Index(es):
Relevant Pages
|