首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

一句Delete语句的有关问题

2012-02-01 
求助一句Delete语句的问题deleteitemwhereidnotin(selectmax(id)fromitemgroupbycast(linkasvarchar(8000)

求助一句Delete语句的问题
delete   item   where   id   not   in(select   max(id)   from   item   group   by   cast(link   as   varchar(8000)))
这句是我的语句,可是item表数据量很大后查询速度就很慢,item表有6万条数据,执行完这句要40秒。

然后我就
delete   item   where   id   not   in(select   max(id)   from   item   group   by   cast(link   as   varchar(8000)))   and   DATEDIFF(day,datetime,getdate())=0
这句目的就是想删除今天重复的数据,可是还是很慢,请问有什么办法可以变快吗?谢谢!

[解决办法]
up
[解决办法]
--try
delete item where id not in (select max(id) from item group by link) and DATEDIFF(day,datetime,getdate())=0

--try
delete item where id not in (select max(id) from item where DATEDIFF(day,datetime,getdate())=0 group by link) and DATEDIFF(day,datetime,getdate())=0

热点排行