SQL儲存過程游標呼叫儲存過程示例

2021-06-13 03:52:14 字數 1144 閱讀 3114

if(object_id('proc_temp','p') is not null)

drop procedure proc_temp

go create procedure proc_temp

with recompile

as select * from student;

goexecute proc_temp;

if(object_id('getmastergoods','p') is not null)

drop procedure getmastergoods

go create procedure getmastergoods

@mycursor cursor varying output

with encryption

as set @mycursor=cursor for

select select goodscode,goodsname from master_goods

open @mycursor

go if(object_id('getallgoodsidandname','p') is not null)

create procedure getallgoodsidandname

as declare @goodscode varchar(18)

declare @goodsname varchar(20)

declare @mastergoodscursor cursor

execute getmastergoods @mastergoodscursor out

fetch next from @mastergoodscursor

into @goodscode,@goodsname

while(@@fetch_status=0)

begin print print @goodscode + ':' + @goodsname

fetch next from @mastergoodscursor

into @goodscode,@goodsname

endclose @mastergoodscursor

deallocate @@mastergoodscursor

go

SQL 儲存過程,游標

if exists select from sysobjects where id object id proc fetch all 事先刪除儲存過程 drop procedure proc fetch all gocreate procedure proc fetch all as 當 set n...

sql呼叫儲存過程

sqlconnection con new sqlconnection configurationmanager.connectionstrings easthhproductquoteconnectionstring tostring con.open sqlcommand cmd new sql...

SQL儲存過程呼叫標量值函式,儲存過程呼叫儲存過程

一 存 儲過程呼叫標量值函式 先建乙個標量值函式,如 create function dbo f num a nvarchar 50 returns nvarchar 50 asbegin declare m nvarchar 50 select m a aad return m end接下來 在儲...