USE [Task]
GO
/****** Object: StoredProcedure [dbo].[pro_name] Script Date: 09/22/2013 10:35:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[pro_name]
@tid int,
@ap float
as
begin
SET NOCOUNT ON;
DECLARE @pid int
DECLARE @AlreadyPercent float
DECLARE @Percents float
DECLARE @total float
if(@ap > 100)
begin
set @ap = 100;
end
--更新记录
update tbTask set AlreadyPercent = round(convert(numeric(6,3),@ap),0) where ID = @tid;
print round(convert(numeric(6,3),@ap),0);
SET @pid = (select top 1 tbTask.ParentTaskID from tbTask where tbTask.ID=@tid);
--如果记录存在,进入循环
IF(@pid is not null and @pid != 0)
BEGIN
set @total = 0;
DECLARE vend_cursor CURSOR
FOR SELECT tbTask.AlreadyPercent,tbTask.Percents FROM tbTask where tbTask.ParentTaskID = @pid
OPEN vend_cursor
FETCH NEXT FROM vend_
SQL Server 存储过程 循环遍历结果集
最新推荐文章于 2022-08-31 17:17:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)