
【游標的詳細用法】declare @id int\猜首睜x0d\x0adeclare @name varchar(50)\x0d\x0adeclare cursor1 cursor for --定義游標cursor1\x0d\x0aselect * from table1 --使用游標的對象(跟據需要填入select文)\x0d\x0aopen cursor1 --打開游標\x0d\x0afetch next from cursor1 into @id,@name --將游標向下穗歲移1行,獲取的數芹滾據放入之前定義的變量@id,@name中\x0d\x0awhile @@fetch_status=0 --判斷是否成功獲取數據\x0d\x0abegin\x0d\x0aupdate table1 set name=name+'1'\x0d\x0awhere id=@id --進行相應處理(跟據需要填入SQL文)\x0d\x0afetch next from cursor1 into @id,@name --將游標向下移1行\x0d\x0aend\x0d\x0aclose cursor1 --關閉游標\x0d\x0adeallocate cursor1
猜你喜歡
- 七宗罪·傲慢之罪·是誰 請詳細解答
- 寧波方特旅游度假區在哪里
- 廣東省江門知名旅游景點及特產介紹 江門屬于哪個省的地方
- 詳細解析哪款更值得購買 華為gt2和gt2pro區別
- 春節去南京旅游會被管控嗎?
- A的伴隨矩陣的特征值怎么求,詳細一點
- 春節適不適合去南京旅游
- 西安朱雀國家森林公園旅游攻略
- 2020年是全面建成小康社會目標的什么年?
- 人畜無害 是 什么意思?詳細的。。。
