insert into dbo.Details(MsgDate, IMSI, Phone, MountCode)
select Date,imsi,Phone,mountcode
from mao as m
where m.imsi not in (select imsi from details)
and m.phone not in (select phone from details)
and len(m.imsi)>=16我写的这个语句在插入数据库中报错
报错信息:
Violation of PRIMARY KEY constraint 'PK_Details'. Cannot insert duplicate key in object 'dbo.Details'.
看着是主键的问题,但是我在语句中已经做了限制了
怎么还插入不进去呢?
select Date,imsi,Phone,mountcode
from mao as m
where m.imsi+ m.phone not in (select imsi+phone from details)
and len(m.imsi)>=16