Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 looping a stored procedure

Author  Topic 

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2004-09-24 : 21:53:47
Hi Tara,spirit,tduggan

I tried this way also ..but its giving me error as.....

Server: Msg 201, Level 16, State 4, Procedure usp_issues_dal, Line 0
Procedure 'usp_issues_dal' expects parameter '@orderId', which was not supplied.


declare @curRow int,@TotalRows int
select identity(int,1,1) RowNum,(SELECT order_id FROM tbl_info_master
where tm_id=15)as order_id,cur_number,
cur_code,cur_description,cur_to into #tempTable
from tbl_issues where tm_id=15

--select * from #temptable

set @TotalRows=@@rowcount + 1

set @curRow=1
while @curRow<@TotalRows
begin
exec usp_issues_dal 'select order_id,cur_number,cur_code,cur_description,cur_to from #tempTable where rownum=@curRow'
set @curRow=@curRow+1

end

drop table #temptable

nr
SQLTeam MVY

12543 Posts

Posted - 2004-09-25 : 15:37:50
You are passing usp_issues_dal a character string which I guess is not whatr it wants

begin
select @order_id=order_id,@cur_number=cur_number,@cur_code=cur_code,@cur_description=cur_description,@cur_to=cur_to from #tempTable where rownum=@curRow
exec usp_issues_dal @order_id,@cur_number,@cur_code,@cur_description,@cur_to
set @curRow=@curRow+1

end


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -