How to Use Cursor
来源:互联网 发布:linux vi显示行数 编辑:程序博客网 时间:2024/05/08 07:17
Below link is a good source for learning cursors in sql
http://www.cnblogs.com/moss_tan_jun/archive/2011/11/26/2263988.html
And I already made a little script for example.
The function of this script is, to check id & dcid for all students,
Then they 2 are not equal then change make this id to dcid's value.
And delete this cursor to free space in RAM.
Please make a cursor by yourself!
DECLARE
test_cursor CURSOR
FOR
select id,DCID FROM STUDENTS where dcid!=id
OPEN test_cursor
DECLARE @ID NVARCHAR(10)
DECLARE @DCID NVARCHAR(10)
FETCH NEXT FROM test_cursor INTO @ID,@DCID
while @@fetch_status=0
begin
print @id
print @dcid
update students set id=@dcid
where dcid=@dcid
fetch next from test_cursor into @id,@dcid
end
close test_cursor
deallocate test_cursor
Feel free to let me know if you have any question about this.
FYI, CSDN forum is a good source for learning everything about PC/MAC.
Here is a link, you can login with WeChat QR code.
http://www.csdn.net/
- How to Use Cursor
- How do I force a query to use bind-aware cursor sharing?
- How To Use DataGird
- how to use typedef
- how to use gz
- How to use chkconfig
- How to use ,,,,
- how to use dialog
- How to use UIDs
- How to use dmalloc
- How to use abld
- How to use BSTR
- How to use Ant
- how to use mstsclib
- how to use gcc
- how to use thread
- how to use ffmpeg
- How to use RDebug
- Ubuntu16.04安装MATLAB2014a
- Windows下mxnet的编译与安装
- Solution for Cut & Divide Text by ',' without Declare or Create Procedure
- DES加密和解密工具Ⅰ
- IPMI命令常用命令设置
- How to Use Cursor
- 【PHP高级】Smarty模板二
- jsp 页面 el表达式无法使用
- js 中数据类型和对象的相关
- Android开发之图片处理框架(二)
- 2016CCPC-Fianl宁波流水账
- Oracle基础
- 权限控制
- How to Use Procedure