update crm_sv_service
set acceptdate = dateadd(day,datediff(day,acceptdate,getdate()) , acceptdate)
where clientid in
(
select clientid from crm_od_header_archive
where inputdate between '2011-11-26' and '2011-12-06'
and
dbo.f_getflag(crm_od_header_archive.id) = 0
)
and batdeliveryid is not null
消息 2601,级别 14,状态 1,第 1 行
不能在具有唯一索引 'IX_CRM_SV_Service_TrackStaff' 的对象 'dbo.crm_sv_service' 中插入重复键的行。
语句已终止。
看看
select dateadd(day,datediff(day,acceptdate,getdate()) , acceptdate) from crm_sv_service
where clientid in
(
select clientid from crm_od_header_archive
where inputdate between '2011-11-26' and '2011-12-06'
and
dbo.f_getflag(crm_od_header_archive.id) = 0
)
and batdeliveryid is not null
group by dateadd(day,datediff(day,acceptdate,getdate()) , acceptdate)
having count(*)>0
--修改
having count(*)>1
sp_helpindex crm_sv_service
里面应该包含了acceptdate字段,且这个索引是唯一索引。