以下是本人在建立多维数据集时对重复客户信息处理所采用的存储过程:
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(@TopCo

本文介绍了一个在SQLServer中删除表中重复客户信息的存储过程。该存储过程通过游标遍历所有重复的客户ID,保留其中一个记录,删除其余重复项,从而实现数据的去重。
最低0.47元/天 解锁文章
1905

被折叠的 条评论
为什么被折叠?



