SQL Server 2000游标使用方法

王朝mssql·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

游标使用方法:

use db1

declare my_cursor cursor scroll dynamic /*scroll表示可随意移动游标指针(否则只能向前),dynamic表示可以读写游标(否则游标只读)*/

for

select 姓名 from 个人资料

open my_cursor

declare @name sysname

fetch next from my_cursor into @name

while(@@fetch_status=0)

begin

print '姓名: ' + @name

fetch next from my_cursor into @name

end

fetch first from my_cursor into @name

print @name

/* update 个人资料 set 姓名='zzg' where current of my_cursor */

/* delete from 个人资料 where current of my_cursor */

close my_cursor

deallocate my_cursor

正文

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航