set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

 

 


ALTER proc [dbo].[BM_GetNumber_Mange]
@BMI_ID varchar(14)
as
declare  @isnull  int
set @isnull=(SELECT  count(*)FROM         BP_ManageIssue INNER JOIN
                      FlowDataV ON BP_ManageIssue.BMI_ID = FlowDataV.MFI_DataID
WHERE     (NOT (FlowDataV.FlowFinish IS NULL)) AND (BP_ManageIssue.BMI_ID = @BMI_ID))
declare  @num varchar(20)
declare  @count int
set @count =(select count(*) from BP_ManageIssue where BMI_Year=datepart(year,getdate()))
begin
if(0<>@isnull)
begin
if(0=@count)
begin
update  BP_ManageIssue  set BMI_Year=datepart(year,getdate()),BMI_Character='中咨计便字'+'['+cast (datepart(year,getdate()) as varchar )+']'+'01'+'号' where BMI_ID=@BMI_ID
end
else if(0<@count and 10>@count)
begin
set @num=(select '0' + cast((select count(*)+1 from BP_ManageIssue where BMI_Year=datepart(year,getdate())) as varchar))
update  BP_ManageIssue  set BMI_Character='中咨计便字'+'['+cast (datepart(year,getdate()) as varchar )+']'+@num+'号', BMI_Year=datepart(year,getdate()) where BMI_ID=@BMI_ID
end
else
begin
set @num=(select count(*)+1 from BP_ManageIssue where BMI_Year=datepart(year,getdate()))
update  BP_ManageIssue  set BMI_Character='中咨计便字'+'['+cast (datepart(year,getdate()) as varchar )+']'+@num+'号', BMI_Year=datepart(year,getdate()) where BMI_ID=@BMI_ID
end
end
end

相关文章:

  • 2021-12-09
  • 2022-03-10
  • 2021-04-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
猜你喜欢
  • 2022-03-07
  • 2022-12-23
  • 2021-08-27
  • 2021-12-06
  • 2021-09-12
  • 2022-12-23
相关资源
相似解决方案