作者在 2009-04-11 14:02:31 发布以下内容
如何去掉重复的内容?
如何将A表根据NO字段,去掉重复的内容(结果如B表)(想使用游标却应为没有索引--无法解决)
A表
NO TS
1 1
1 1
1 1
2 2
2 2
2 2
3 3
3 3
4 4
2 2
1 1
B表
NO TS
1 1
2 2
3 3
4 4
A表
NO TS
1 1
1 1
1 1
2 2
2 2
2 2
3 3
3 3
4 4
2 2
1 1
B表
NO TS
1 1
2 2
3 3
4 4
------------------------------------------------------------
--> 测试数据: @A
declare @A table ([NO] int,[TS] int)
insert into @A
select 1,1 union all
select 1,1 union all
select 1,1 union all
select 2,2 union all
select 2,2 union all
select 2,2 union all
select 3,3 union all
select 3,3 union all
select 4,4 union all
select 2,2 union all
select 1,1
select distinct * from @A
/*
NO TS
-------------
1 1
2 2
3 3
4 4
*/
declare @A table ([NO] int,[TS] int)
insert into @A
select 1,1 union all
select 1,1 union all
select 1,1 union all
select 2,2 union all
select 2,2 union all
select 2,2 union all
select 3,3 union all
select 3,3 union all
select 4,4 union all
select 2,2 union all
select 1,1
select distinct * from @A
/*
NO TS
-------------
1 1
2 2
3 3
4 4
*/