首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2013-03-21 
SQL存储过程游标调用存储过程示例if(object_id(proc_temp,p) is not null)DROP PROCEDURE proc_tempgo

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


热点排行