0
我想在SQL Server中複製以下代碼。我周圍有一看,這似乎是唯一的選擇是隻用一條直線光標,但有沒有更好的辦法:在Oracle中批量收集的SQL Server等效
DECLARE
CURSOR cursor1 IS
SELECT *
FROM table1;
TYPE cursor_aat IS TABLE OF cursor1%ROWTYPE;
l_cursor cursor_aat;
BEGIN
OPEN cursor1;
LOOP
FETCH cursor1
BULK COLLECT INTO l_cursor LIMIT 200;
FOR INDX IN 1 .. l_cursor.COUNT LOOP
IF (CheckSomeData() = 0) THEN
INSERT INTO new_table
(col1, col2)
values
(l_cursor(INDX).col1, l_cursor(INDX).col2);
INSERT INTO new_table2
...
end if
END LOOP;
EXIT WHEN l_cursor.COUNT < 200;
...