Cursor usage

xiaoxiao2021-03-06  57

Cursor usage: Use db1declare my_cursor cursor scroll Dynamic / * Scroll indicates that the cursor pointer (otherwise only forward), Dynamic means reading and writing a cursor (otherwise the cursor read only) * / forselect Name from personal information open my_cursordeclare @name sysnamefetch next from my_cursor into @namewhile (@@ fetch_status = 0) begin print 'name:' @name fetch next from my_cursor into @name endfetch first from my_cursor into @nameprint @ name / * update personal data set name = 'zzg' where current of my_cursor * // * delete from personal data where current of my_cursor * / close my_cursordeallocate my_cursorh first from my_cursor into @nameprint @ name / * update personal data set name = 'zzg' where current of my_cursor * // * delete from Personal information where current of my_cursor * / close my_cursordectocate my_cursor

转载请注明原文地址:https://www.9cbs.com/read-91332.html

New Post(0)