Create Table ReRowTest
(
ID int not null,
Name varchar(50)
)
insert into ReRowTest values(1,3)
insert into ReRowTest values(1,3)
insert into ReRowTest values(1,3)
insert into ReRowTest values(1,3)
insert into ReRowTest values(2,4)
insert into ReRowTest values(2,4)
insert into ReRowTest values(2,4)
insert into ReRowTest values(3,5)
insert into ReRowTest values(3,5)
insert into ReRowTest values(3,5)
SQL语句:
Select Distinct * into #tempTable From ReRowTest
Delete From ReRowTest
insert ReRowTest Select * From #tempTable
Drop table #tempTable
Select * From ReRowTest 结果为:
ID Name
1 3
2 4
3 5
如果常用可以封装成SQL存储过程