34,590
社区成员
发帖
与我相关
我的任务
分享
-- 建测试表
create table LR(LRId int not null identity(1,1))
-- 插入2条重复LRId的记录
set identity_insert LR on
insert into LR(LRId) select 101
insert into LR(LRId) select 101
set identity_insert LR off
-- 检查重复
select LRId,
count(1) 'qty'
from LR
group by LRId
having count(1)>1
/*
LRId qty
----------- -----------
101 2
(1 row(s) affected)
*/