当前位置: 代码迷 >> SQL >> SQL存储过程游标调用存储过程示范
  详细解决方案

SQL存储过程游标调用存储过程示范

热度:96   发布时间:2016-05-05 12:21:32.0
SQL存储过程游标调用存储过程示例
if(object_id('proc_temp','p') is not null)DROP PROCEDURE proc_tempgo CREATE PROCEDURE proc_tempwith recompileAS  SELECT * FROM student;GOEXECUTE proc_temp;IF(object_id('GetMasterGoods','p') is not null)DROP PROCEDURE GetMasterGoodsGO CREATE PROCEDURE GetMasterGoods@MyCursor CURSOR VARYING OutputWITH encryptionAS set @MyCursor=CURSOR FOR   SELECT Select GoodsCode,GoodsName From Master_Goods OPEN @MyCursorGO IF(object_id('GetAllGoodsIDAndName','p') is not null)CREATE PROCEDURE GetAllGoodsIDAndNameAS DECLARE @GoodsCode VARCHAR(18)DECLARE @GoodsName VARCHAR(20)DECLARE @MasterGoodsCursor CURSOREXECUTE GetMasterGoods @MasterGoodsCursor OUTFETCH Next FROM @MasterGoodsCursorINTO @GoodsCode,@GoodsNameWHILE(@@Fetch_Status=0)  BEGIN Print Print @GoodsCode + ':' + @GoodsName     FETCH Next FROM @MasterGoodsCursor    INTO @GoodsCode,@GoodsNameEndCLOSE @MasterGoodsCursorDEALLOCATE @@MasterGoodsCursorGO


  相关解决方案