col1+','+col2+','...col5 联合主键
select * from table where col1+','+col2+','...col5 not in ( select max(col1+','+col2+','...col5) from table group by col1,col2,col3,col4
)
group by 子句后跟的字段就是你用来判断重复的条件,如只有col1,那么只要col1字段内容相同即表示记录相同。2,
select identity(int,1,1) as id,* into #temp from tabel
delect # where id not in (
select max(id) from # group by col1,col2,col3...)
delect table
inset into table(...)
select ..... from #temp
select * from table where col1+','+col2+','...col5 not in ( select max(col1+','+col2+','...col5) from table group by col1,col2,col3,col4
)
group by 子句后跟的字段就是你用来判断重复的条件,如只有col1,那么只要col1字段内容相同即表示记录相同。2,
select identity(int,1,1) as id,* into #temp from tabel
delect # where id not in (
select max(id) from # group by col1,col2,col3...)
delect table
inset into table(...)
select ..... from #temp
group by id2,id3,id4,id5 having conut(*)>1) b
where a.id2=b.id3 and a.id3=b.id3 and b.id4=a.id4 and a.id5=b.id5
select * from table where col1+','+col2+','...col5 in ( select max(col1+','+col2+','...col5) from table
where having count(*)>1
group by col1,col2,col3,col4
)
group by 子句后跟的字段就是你用来判断重复的条件,如只有col1,那么只要col1字段内容相同即表示记录相同。2,
select identity(int,1,1) as id,* into #temp from tabel
select * from #temp where id in (
select max(id) from #emp where having count(*)>1 group by col1,col2,col3...)
where newfield not in(
select min(newfield) from 表 group by col1,col2,col3,col4
)alter table 表 drop column newfield
select * from table where id in (select id from table group by col1,col2,col3,col4 having count(id)>1