March 24, 2009 at 5:04 am
Hi People,
I have a query like this and I want to replace cursor with while loop because I learned that cursors are much slower and utilizes much of resources... the problem is that the OUPUT clause I believe can only be used with a CURSOR datatype to which I am not very sure... can some body suggest
DECLARE @mycur CURSOR
DECLARE @ins VARCHAR (16)
DECLARE @rent INT
exec my_childsp
@var,
@var2,
@var3,
@var4,
@mycur OUTPUT
fetch next FROM @mycur INTO @ins, @rent
while @@fetch_status = 0
BEGIN
INSERT INTO #temptable values (@ins, @rent)
fetch next FROM @mycur INTO @ins, @rent haverent
END
March 24, 2009 at 9:57 am
Hi
I've never used the OUTPUT feature but had a look to BOL. Seems that it returns the cursor as output.
Why do you not just return the data as SELECT from your procedure and use temp/variable table as destination and goon with this?
Greets
Flo
March 24, 2009 at 10:09 am
It would help to see the actual code you are trying to replace. In addition changing from a cursor to a while loop doesn't really change much, it is still RBAR. You really need to look at finding a seet based solution to replace your cursor based solution.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply