[dbo].[将号码状态修改为0]存储过程

峰哥:
这个存储过程是用来将延时后号码的state状态修改为0
下面是我写的存储过程请审批
谢谢!

注意

1.新增代码为蓝色(包括修改)

2.测试代码为绿色

3.删除代码为红色


create PROCEDURE [dbo].[将号码状态修改为0]
        @sum int,  --操作的数量
        @id int, --号码id
        @yys int,--号码类型
        @from_channel varchar(30), --父渠道
        @from_channel_child varchar(30) --子渠道
AS
begin
SET NOCOUNT ON
        declare @Phonesum varchar(10)--转化的操作多少笔的数量
        declare @flag nvarchar(5) --卡类型转换为汉语
  declare @Phoneid varchar(10) --释放号码id转化类型
  if(@sum>200)
        begin
                  return
        end
  update top(@sum) do_phone  set state=0 where isfinal=0 and id=isnull(@id,id) and yys=isnull(@yys,yys)    and from_channel_child=isnull(@from_channel_child,from_channel_child) and from_channel=isnull(@from_channel,from_channel) and state in(1099,20130501) and MaxEndTime>dateadd(n,20,GETDATE())
        if(@@rowcount>0)
        begin
                  print '成功'
     if(@yys=null)
           begin
                  set @flag=''
           end
           else  if(@yys=0)
           begin
                  set @flag='移动'
           end
           else if(@yys=1)
           begin
                  set @flag='联通'
           end
           else if(@yys=2)
           begin
                 set @flag='电信'
           end 
           set @Phonesum=convert(varchar(10),@sum) --转换类型
     set @Phoneid=convert(varchar(10),ISnull(@id,0)) --转换类型
           insert into [dbo].[log_OperationSupport](Operator,Content,Createtime) values(SUSER_NAME(),isnull(@from_channel,'')+'父渠道和'+isnull(@from_channel_child,'')+'子渠道的'+@flag+''+@Phoneid+'号码状态修改为0一共修改了'+@Phonesum+'笔',getdate())
         end
         else
         begin
                 print '失败'
         end
end
 
原文地址:https://www.cnblogs.com/ComputerVip/p/11624731.html