批量修改数据、删除重复数据

根据ID计算该ID的访问量,并将该数值更新到主表
不知道还有没有好的方法

declare @table table (i_pid int,i_count int)
insert into @table(i_pid,i_count)
select   p_id ,COUNT(*) from  un_tbl_Visit  group by p_id

update  ProductOther set  Po_TotalDown=i_count from @table,ProductOther  where i_pid=P_ID

删除重复数据
1、delete   from   t1     where   exists(select   1   from   t1   a   where     a.id>t1.id   and   t1.col1=a.col1)   
2、alter   table   t1   add   (id   int   identity(1,1))   
  delete   from   t1    
  where   id   not   in   (select   min(id)   from   t1   group   by   column   having   count(*)   >   0)   

3、  delete   from   music   a1   where   a1.rowid<>(select   max(rowid)   from   music   a2   where   a1.id=a2.id   )

考虑一下,第一条处理方案最好,方案3也不错,rowid是Oracle特有的,不过根据唯一标识在别的数据库也一样处理



 

你可能感兴趣的:(删除)