一個簡單的例子,想測試下,但好像不能更新email,不知道問題在哪裏?
declare my_cur CURSOR for select email from tbl_user
open my_cur
while @@fetch_status=0
begin
update tbl_user set email='test' where current of my_cur
fetch next from my_cur
end
DECLARE My_Cur CURSOR SCROLL DYNAMIC
FOR
SELECT Email FROM MyUser
OPEN My_Cur
FETCH next FROM My_Cur
WHILE (@@FETCH_STATUS=0)
BEGIN
UPDATE MyUser SET Email='Just For Test' WHERE CURRENT OF My_Cur
FETCH next FROM My_Cur
END
DEALLOCATE My_Cur
DECLARE My_Cur CURSOR SCROLL DYNAMIC
FOR
SELECT Email FROM MyUser
OPEN My_Cur
FETCH next FROM My_Cur
WHILE (@@FETCH_STATUS=0)
BEGIN
UPDATE MyUser SET Email='Just For Test' WHERE CURRENT OF My_Cur
FETCH next FROM My_Cur
END
DEALLOCATE My_Cur