青青草免费线看线看|啊在车上停不下来了|国产少女免费观看电视剧|仑乱88MAV|精品老司机在线观看视频|国产一区二区三区高清免费视频|在线观看免费777av

游標的詳細用法


游標的詳細用法


【游標的詳細用法】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

    猜你喜歡