以下是本人在建立多维数据集时对重复客户信息处理所采用的存储过程:
create procedure Sp_DeleteDuplicateCustomerInfo
as
declare @CustomerId bigint
declare @Count int
declare @TopCount int
declare @StrCustomerId char(7)
declare @StrTopCount char(1)
declare deleteCur cursor for
select CustomerId,count(customerID) counts from T_CustomerInfo group by customerID
having count(customerID)>1
open deleteCur
fetch next from deleteCur into @CustomerId,@Count
while @@fetch_status=0
begin
set @TopCount=@Count-1
set @StrCustomerId = cast(@CustomerId as char(7))
set @StrTopCount = cast(@TopCount as char(1))
print 'delete from T_CustomerInfo where recId in
(select top '+cast(