February 11, 2009 at 7:01 am
Hi all.
I have the following code:
DECLARE prod_cursor CURSOR
FOR
SELECT productid <--Problem child
FROM @products
OPEN prod_cursor
DECLARE @prodid_
FETCH NEXT FROM prod_cursor INTO @prodid_
WHILE (@@FETCH_STATUS <> -1)
BEGIN
IF(@@FETCH_STATUS <> -2)
BEGIN
(line by line processing)
END
FETCH NEXT FROM prod_cursor INTO @prodid_
END
CLOSE prod_cursor
DEALLOCATE prod_cursor
SELECT * from @prodid_
Problem is that I am getting the cursor select's result first then the last select's result set. I only want the last result set. Is there a way i can supress the cursor result set?
many thanks
birdie3321
February 11, 2009 at 7:37 am
Answered here in detail
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=119624
N 56°04'39.16"
E 12°55'05.25"
February 11, 2009 at 7:56 am
Thanks peso... I am looking for different solutions...unfortunately i am not a T-SQL wiz and was hoping for something a little more straight forward; e.g., is there an obscure option on the FETCH statement that i could use?
February 11, 2009 at 8:42 am
As told in other thread, you don't need doubled nested cursors.
All it takes is one update statement and one insert statement.
N 56°04'39.16"
E 12°55'05.25"
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply