也是一个做内部项目时用到的例子,以备参考。
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [GetProjProgress]
-- Add the parameters for the stored procedure here
@iProjectId int
--以 out 输出也可
--@iChaoqi int out
AS
DECLARE
--临时结果
@iTemp int,
--返回当前进度
@iProgress int
BEGIN
if exists(select * from Project_InfoList where ProjectId=@iProjectId)
begin
set @iProgress = 10;
end
if @iProgress >= 10 begin
set @iTemp = 0;
select @iTemp=TypeId from project_ReportContent where ReportId=(
select ReportID from project_Report where ProjectId=@iProjectId and ReportVersion=(
select MAX(ReportVersion) from project_Report where ProjectId=@iProjectId))
--咨询报告四种状态1 2 3 4
Select @iProgress=
CASE
WHEN @iTemp = '1' THEN 50
WHEN @iTemp = '2' THEN 55
WHEN @iTemp = '3' THEN 60
WHEN @iTemp = '4' THEN 65
ELSE @iProgress
END
end
print @iProgress;
return @iProgress;
END