在项目中用到的对号码的类别进行识别,如:AAAA,ABAB等待。
   保留以备后用。
对号码进行分类的触发器SET QUOTED_IDENTIFIER OFF 
对号码进行分类的触发器
GO
对号码进行分类的触发器
SET ANSI_NULLS ON 
对号码进行分类的触发器
GO
对号码进行分类的触发器
对号码进行分类的触发器
CREATE TRIGGER [testTrigger] ON [dbo].[Phone] 
对号码进行分类的触发器
FOR INSERTUPDATE
对号码进行分类的触发器
AS
对号码进行分类的触发器
declare     @Level2 char(10),
对号码进行分类的触发器    
@Level3 char(10),
对号码进行分类的触发器    
@phone char(11),
对号码进行分类的触发器    
@first             char(1),
对号码进行分类的触发器         
@second       char(1),
对号码进行分类的触发器         
@third            char(1),
对号码进行分类的触发器         
@last              char(1)
对号码进行分类的触发器
对号码进行分类的触发器
select @phone=phonenum from inserted
对号码进行分类的触发器
select @first = substring(@phone,8,1)
对号码进行分类的触发器
select @second = substring(@phone,9,1)
对号码进行分类的触发器
select @third = substring(@phone,10,1)
对号码进行分类的触发器
select @last = substring(@phone,11,1)
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器            
-- 普号无4
对号码进行分类的触发器
            if (charindex('4'@phone )=0)
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='普号'
对号码进行分类的触发器                
set @Level3='无4'
对号码进行分类的触发器            
end
对号码进行分类的触发器                       
--差号含4
对号码进行分类的触发器
            if (charindex('4'@phone)!=0)
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='差号'
对号码进行分类的触发器                
set @Level3='号码含4'
对号码进行分类的触发器            
end
对号码进行分类的触发器
对号码进行分类的触发器        
--差号尾数含4
对号码进行分类的触发器
            if (charindex('4'substring(@phone,8,5) )!=0)
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='差号'
对号码进行分类的触发器                
set @Level3='尾数含4'
对号码进行分类的触发器            
end
对号码进行分类的触发器            
--134
对号码进行分类的触发器
            if (substring(@phone,0,4="134")
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='差号'
对号码进行分类的触发器                
set @Level3='134号段'
对号码进行分类的触发器            
end
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器                
对号码进行分类的触发器            
--ABAB
对号码进行分类的触发器
            if (@first=@third and @second=@last and @first<>@second )
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='特号'
对号码进行分类的触发器                
set @Level3='ABAB'
对号码进行分类的触发器            
end
对号码进行分类的触发器    
对号码进行分类的触发器                                
--AABB
对号码进行分类的触发器
            if (  @first=@second and @third=@last and @first<>@third )
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='特号'
对号码进行分类的触发器                
set @Level3='AABB'
对号码进行分类的触发器            
end
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器            
--ABC
对号码进行分类的触发器
            if (  convert(int,@last)=convert(int,@third)+1 and convert(int,@third)=convert(int,@second)+1  and  charindex('4',@phone)=0)
对号码进行分类的触发器                
begin
对号码进行分类的触发器                    
set @Level2='优选号码'
对号码进行分类的触发器                    
set @Level3='ABC'
对号码进行分类的触发器                
end
对号码进行分类的触发器            
对号码进行分类的触发器
对号码进行分类的触发器            
--ABCD
对号码进行分类的触发器
            if ( convert(int,@last)=convert(int,@third)+1 and convert(int,@third)=convert(int,@second)+1 and convert(int,@second)=convert(int,@first)+1 )
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='特号'
对号码进行分类的触发器                
set @Level3='ABCD'
对号码进行分类的触发器            
end
对号码进行分类的触发器            
对号码进行分类的触发器            
对号码进行分类的触发器
对号码进行分类的触发器            
--AAAB
对号码进行分类的触发器
            if (@first=@second and @second=@third and @third<>@last and  charindex('4',@phone)=0)
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='优选号码'
对号码进行分类的触发器                
set @Level3='AAAB'
对号码进行分类的触发器            
end
对号码进行分类的触发器
对号码进行分类的触发器            
--ABBA
对号码进行分类的触发器
            if (@first=@last and @second=@third and @first<>@second and  charindex('4',@phone)=0)
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='优选号码'
对号码进行分类的触发器                
set @Level3='ABBA'
对号码进行分类的触发器            
end
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器            
--AA
对号码进行分类的触发器
            if (@third=@last and  charindex('4',@phone)=0)
对号码进行分类的触发器                
begin
对号码进行分类的触发器                    
set @Level2='优选号码'
对号码进行分类的触发器                    
set @Level3='AA'
对号码进行分类的触发器                
end
对号码进行分类的触发器            
对号码进行分类的触发器            
--AAA
对号码进行分类的触发器
                if (@second=@third and @third=@last)
对号码进行分类的触发器                
begin
对号码进行分类的触发器                    
set @Level2='特号'
对号码进行分类的触发器                    
set @Level3='AAA'
对号码进行分类的触发器                
end
对号码进行分类的触发器
对号码进行分类的触发器            
--AAAA
对号码进行分类的触发器
            if (@first=@second and @second=@third and @third=@last)
对号码进行分类的触发器            
begin
对号码进行分类的触发器                
set @Level2='特号'
对号码进行分类的触发器                
set @Level3='AAAA'
对号码进行分类的触发器            
end
对号码进行分类的触发器            
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
对号码进行分类的触发器
update phone set phone.hlr=PhoneNumLevel1.hlr,level1=ModelNum,level2=@level2,level3=@level3 
对号码进行分类的触发器
from PhoneNumLevel1 INNER JOIN phone on 
对号码进行分类的触发器 
right(NumRange,7)=left(phonenum,7)  where phonenum=@phone
对号码进行分类的触发器
对号码进行分类的触发器
GO
对号码进行分类的触发器
SET QUOTED_IDENTIFIER OFF 
对号码进行分类的触发器
GO
对号码进行分类的触发器
SET ANSI_NULLS ON 
对号码进行分类的触发器
GO
对号码进行分类的触发器
对号码进行分类的触发器

相关文章: