当前位置:数据库 > SQLServer >>

SQL Server 2000游标使用方法

答案:
游标使用方法:
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
正文 

上一个:网址管理专家 1.5 优化版 (免费版本) 请大家测试
下一个:数据库设计经验

Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,