自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

SQL Server游標(biāo)和存儲過程共同使用的例子

數(shù)據(jù)庫 SQL Server
SQL Server游標(biāo)和存儲過程都是SQL Server中非常重要的,如果能夠一起使用,自然再好不過,下面為您舉例說明SQL Server游標(biāo)和存儲過程共同使用的的方法,供您參考。

下面為您介紹的例子共同使用了SQL Server游標(biāo)和SQL Server存儲過程,如果您SQL Server游標(biāo)和存儲過程都比較感興趣的話,不妨一看。

  1. If Object_ID('dbo.GetMasterGoods') Is Not Null  
  2.            Drop Proc dbo.GetMasterGoods  
  3.      Go  
  4.  
  5.      Create Proc GetMasterGoods  
  6.      @MyCursor Cursor Varying Output  
  7.      With Encryption  
  8.      As   
  9.             Set @MyCursor = Cursor  
  10.             For  
  11.                    Select GoodsCode,GoodsName From Master_Goods  
  12.      Open @MyCursor  
  13.      Go  
  14.  
  15.      --下邊建立另外一個存儲過程,用于遍歷游標(biāo)輸出結(jié)果  
  16.  
  17.      Create Proc GetAllGoodsIDAndName  
  18.      As  
  19.  
  20.      Declare @GoodsCode varchar(18)  
  21.      Declare @GoodsName nvarchar(20)  
  22.      Declare @MasterGoodsCursor Cursor  
  23.      Exec GetMasterGoods @MasterGoodsCursor out  
  24.      Fetch Next From @MasterGoodsCursor  
  25.      InTo @GoodsCode,@GoodsName  
  26.      While(@@Fetch_Status = 0)  
  27.      Begin  
  28.             Begin  
  29.                    Print @GoodsCode + ':' + @GoodsName  
  30.             End  
  31.             Fetch Next From @MasterGoodsCursor  
  32.             InTo @GoodsCode,@GoodsName  
  33.      End  
  34.      Close @MasterGoodsCursor  
  35.      Deallocate @MasterGoodsCursor  
  36.      Go  

以上就是SQL Server游標(biāo)和存儲過程共同使用的方法。

 

【編輯推薦】

帶您學(xué)習(xí)SQL存儲過程

SQL Server SA權(quán)限小技巧

SQL數(shù)據(jù)庫操作授權(quán)

SQL Server游標(biāo)種類介紹

SQL Server用戶權(quán)限詳解

責(zé)任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-09-01 15:09:41

DB2動態(tài)游標(biāo)

2010-09-14 10:16:57

sql server

2011-03-31 10:38:28

SQL Server編寫優(yōu)化

2010-07-15 12:38:14

SQL Server存

2011-03-24 13:38:47

SQL Server 存儲分頁

2011-03-28 10:28:46

sql存儲過程

2010-10-20 16:17:17

SQL Server角

2009-08-06 16:44:06

2011-09-01 15:40:42

SQL Server存儲過程和存儲函數(shù)的加

2010-09-16 16:23:06

sql server批

2010-11-10 13:03:15

SQL Server存

2010-04-26 14:12:23

Oracle使用游標(biāo)觸

2010-11-12 09:46:55

Sql Server存

2010-09-14 10:36:23

sql server存

2011-03-28 10:46:36

sql server存儲分頁

2010-10-09 16:41:54

MYSQL存儲過程

2012-05-10 11:17:23

JavaSQL Server

2010-09-25 16:00:38

sql存儲過程

2010-09-14 10:47:45

sql server存

2010-11-10 15:47:59

點贊
收藏

51CTO技術(shù)棧公眾號