新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
SQL Server游標(biāo)實(shí)例大集合
此文章主要講述的是SQL Server游標(biāo)實(shí)例,以及對(duì)當(dāng)前SQL Server游標(biāo)的數(shù)據(jù)進(jìn)行修改的方法與刪除當(dāng)前游標(biāo)行數(shù)據(jù)的實(shí)際操作方法的描述,以下就是文章的主要內(nèi)容的詳細(xì)描述,望大家在瀏覽之后會(huì)對(duì)其有更深的了解。

- Declare MyCusror Cursor Scroll
- For Select * From Master_Goods Order By GoodsID
- Open MyCursor
- Fetch next From MyCursor
- Into @GoodsCode,@GoodsName
- While(@@Fetch_Status = 0)
- Begin
- Begin
- Select @GoodsCode = Convert(Char(20),@GoodsCode)
- Select @GoodsName = Convert(Char(20),@GoodsName)
- PRINT @GoodsCode + ':' + @GoodsName
- End
- Fetch next From MyCursor
- Into @GoodsCode,@GoodsName
- End
- Close MyCursor
- Deallocate MyCursor
修改當(dāng)前SQL Server游標(biāo)的數(shù)據(jù)方法如下:
- UpDate Master_Goods Set GoodsName = 'yangyang8848' Where Current Of MyCursor;
刪除當(dāng)前游標(biāo)行數(shù)據(jù)的方法如下:
- Delete From Master_Goods Where Current Of MyCursor
Select @@CURSOR_ROWS 可以得到當(dāng)前SQL Server游標(biāo)中存在的數(shù)據(jù)行數(shù)。注意:此變量為一個(gè)連接上的全局變量,因此只對(duì)應(yīng)***一次打開的游標(biāo)。
上述的相關(guān)內(nèi)容就是對(duì)SQL Server游標(biāo)實(shí)例的描述,希望會(huì)給你帶來(lái)一些幫助在此方面。
【編輯推薦】
- 快速對(duì)SQL Server鎖機(jī)制進(jìn)行掌握的竅門
- SQL Server存儲(chǔ)圖像數(shù)據(jù)大閱兵
- SQL Server復(fù)制和其相關(guān)的工作原理
- SQL Server重復(fù)數(shù)據(jù)刪除的2個(gè)操作方案
- SQL Server游標(biāo)實(shí)例演示,不得不看!
當(dāng)前名稱:SQL Server游標(biāo)實(shí)例大集合
標(biāo)題鏈接:http://fisionsoft.com.cn/article/djpegsc.html


咨詢
建站咨詢
