标签:from update dea desc and declare style while 删除存储
--创建存储过程
create procedure [dbo].[updateMuLuBeiZu]
AS
Declare @archgid VARCHAR(1000),
@bz VARCHAR(max),
@strSql nvarchar(max)
begin
Declare curStudentFee Cursor for
select archgid,bz from ARCH where BZ is not null and BZ <>‘‘
Open curStudentFee
Fetch Next From curStudentFee into @archgid,@bz;
while(@@FETCH_STATUS=0)
begin
set @strSql=‘update CASE set BZ=‘‘‘+@bz+‘‘‘‘+‘where ID0 = (select top 1 ID0 from CASE t where t.ARCHGID=‘‘‘+@archgid+‘‘‘‘+‘ order by t.INDEXID desc)‘
exec
(@strSql)
Fetch Next From curStudentFee into @archgid,@bz;
end
Close curStudentFee
Deallocate curStudentFee;
end
GO
--执行存储过程
exec updateMuLuBeiZu ;
--删除存储过程
drop procedure updateMuLuBeiZu;
存储过程-基础用法
标签:from update dea desc and declare style while 删除存储
原文地址:http://www.cnblogs.com/dahuo/p/7770664.html