यदि आप नीचे लूप के साथ अपने लूप को कोड करते हैं (लूप से पहले प्रारंभिक fetch के साथ) जारी है तो बस आपको शीर्ष पर कूद जाएगा, और उसी पंक्ति को फिर से संसाधित करेगा। आप नीचे दिए गए fetch भाग पर कूदने के लिए एक गोटो का उपयोग कर सकते हैं या शीर्ष पर लाने के लिए लूप को पुन: स्थापित कर सकते हैं और cointinue काम करेगा।
आप अपने पाश गोटो उपयोग करने के लिए संशोधित कर सकता है ...
...
...
if <condition>
BEGIN
GOTO Fetch_Next
END
....
....
Fetch_Next:
FETCH NEXT FROM ...
यहाँ केवल एक पाश के शीर्ष पर लाने के लिए कुछ नमूना कोड है, काम करेंगे जारी रखने के लिए:
DECLARE <cursor_name> CURSOR FOR
SELECT
FROM
WHERE
FOR READ ONLY
--populate and allocate resources to the cursor
OPEN <cursor_name>
--process each row
WHILE 1=1
BEGIN
FETCH NEXT FROM <cursor_name>
INTO @a, @b, @c
--finished fetching all rows?
IF @@FETCH_STATUS <> 0
BEGIN --YES, all done fetching
--exit the loop
BREAK
END --IF finished fetching
--do something here--
--do something here--
IF <your condition>
BEGIN
CONTINUE -- fetch next row
END
--do something here--
--do something here--
END --WHILE
--close and free the cursor's resources
CLOSE <cursor_name>
DEALLOCATE <cursor_name>
स्रोत
2009-07-24 17:49:32
धन्यवाद कि सही जवाब है। – codingguy3000