July 4, 2010 at 10:29 pm
I have a SP which is like this
SPNAME Param1,param2
BEGIN
....Some Processing
SELECT * FROM #tempTable
END
I want to execute this stored procedure for multiple param2 and all of the values of param2 will be coming from a cursor. So i want to execute the stored procedure in a cursor loop.
Problem is that i want to enter every table value returned from stored procedure in a single table
Right now when i a m executing through cursor loop it is giving one table per execution cycle. Like for every param2 value it is returning one table
Please suggest how to do that.
July 5, 2010 at 1:28 am
Create one table like result in your database with exact output column , insert the values row by row (in your sub procedures used by cursor.) ,
finally end of cursor you can use select * from result & clear the table rows...
July 5, 2010 at 1:53 am
is there any solution other than this. I dont want to create a table in database. Because as and when i will be running the stored procedure one entry will be going into datatabase table.
July 5, 2010 at 2:19 am
Hi there, cursors are really pain-givers.. without your original "..Some Processing" code, we cant give an alternative..
but within the cursors u can use like this
create table #table ( your column names and data-types)
declare param1 , param2
Declare yourcursor cursor
select param1value, param2value from basetable
open yourcursor
fetch next into param1 , param2
while @@fetch_status = 0
begin
insert into #table
exec yourstoreprocedure param1 , param2
fetch next into param1 , param2
end
close yourcursor
deallocate yourcursor
Hope this helps!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply