这个没用 ,DATEDIFF(ss,startdate,enddate)<10 startdate和enddate 是多对多的关系 select * from Hemm_Weibo_Sending AS ds where GUID in (select GUID from Hemm_Weibo_Sending as sb where datediff(ss,ds.RunDate,sb.RunDate)<10 and ds.TacticId = sb.TacticId) 执行也找不出在10秒内重复的数据
with TB as ( select GUID,TacticId,RunDate,ROW_NUMBER() over(partition by TacticId order by RunDate) as rowid from tablename)delete from tablename where guid in ( select b.guid from TB as a inner join TB as b on a.rowid=b.rowid-1 and a.TacticId=b.TacticId where DATEDIFF(S,b.RunDate,a.RunDate)<10)
rowid 貌似GUID是行号 前面没有序号
SELECT [GUID] ,[TacticId] ,[RunDate] FROM [Hemm_Weibo_Sending] 这是表结构 ,就三个字段,没有外键,和引用
这个没用 ,DATEDIFF(ss,startdate,enddate)<10 startdate和enddate 是多对多的关系
select * from Hemm_Weibo_Sending AS ds
where GUID in
(select GUID from Hemm_Weibo_Sending as sb
where datediff(ss,ds.RunDate,sb.RunDate)<10 and ds.TacticId = sb.TacticId)
执行也找不出在10秒内重复的数据
select GUID,TacticId,RunDate,ROW_NUMBER() over(partition by TacticId order by RunDate) as rowid
from tablename)delete from tablename where guid in (
select b.guid
from TB as a inner join TB as b on a.rowid=b.rowid-1 and a.TacticId=b.TacticId
where DATEDIFF(S,b.RunDate,a.RunDate)<10)
,[TacticId]
,[RunDate]
FROM [Hemm_Weibo_Sending]
这是表结构 ,就三个字段,没有外键,和引用