Looping Cursor SQL Server
[sql]
DECLARE
@DocID INT
DECLARE MyCursor CURSOR LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR SELECT
a.doc_id
FROM Sales.[Invoice.Header] a
WHERE a.doc_id IS NULL
OPEN Mycursor
FETCH NEXT FROM MyCursor INTO
@DocID
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT
@DocID
FETCH NEXT FROM MyCursor INTO
@DocID
END
CLOSE MyCursor
DEALLOCATE MYcursor
[/sql]
[sql]
DECLARE
@DocID INT
DECLARE MyCursor CURSOR LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR SELECT
a.doc_id
FROM Sales.[Invoice.Header] a
WHERE a.doc_id IS NULL
OPEN Mycursor
FETCH NEXT FROM MyCursor INTO
@DocID
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT
@DocID
FETCH NEXT FROM MyCursor INTO
@DocID
END
CLOSE MyCursor
DEALLOCATE MYcursor
[/sql]
Komentar
Posting Komentar