日期:2014-05-18  浏览次数:20602 次

求一个统计电话号码个数的存储过程
SELECT [SendTels] FROM [ZW_User_duanxin] where number=1

已知上述sql得出如下电话号码,分别是6条记录
--------------------------
14002727924  
14002727924 14002727926  
14002727924 14002727926 14002727927  
84002727926 84002727927 84002727928 84002727928  
84002727924 84002727926 84002727927 84002727928  
14002727924 14002727926 14002727927 14002727928 84002727928  
--------------------------
 
用怎样才存储过程可以得到所有电话号码的总和!重复号码也算。

------解决方案--------------------
SQL code

declare @t table (col ntext)
insert into @t
select '10002727920 10002727926 10002727927 10002727928 ' union all
select '10002727920 10002727926 10002727927 10002727928 ' union all
select '10002727920 10002727926 10002727927 10002727928 ' union all
select '80002727926 80002727927 80002727928 11111111111 22222222222 ' union all
select '80002727920 80002727926 80002727927 80002727928' union all
select '10002727920 10002727926 10002727927 10002727928' union all
select '13609303497' union all
select '18609489876' union all
select '18609489876' union all
select '10002627920' union all
select '10002627920' union all
select '10002627920' 
select 
sum(ceiling(len(cast(col as varchar(8000)))/12.00)) from @t
/*
31
*/