当前位置: 代码迷 >> Sql Server >> 简单有关问题 ,请帮忙解决!多谢
  详细解决方案

简单有关问题 ,请帮忙解决!多谢

热度:23   发布时间:2016-04-27 20:59:18.0
简单问题 ,请帮忙解决!谢谢
字段   :   row       (该字段数据不连续,有重复数据)
数据:   2
            2
            3
            5
            6
            8
          .....

如何把该字段的数据(不重复)[email protected]   ?

------解决方案--------------------
如果只是取出不重復的數據,這樣也可以
Select row from 表 Group By row
------解决方案--------------------
drop table tbtest
go
create table tbtest(row int)
insert into tbtest
select 2
union all select 2
union all select 3
union all select 5
union all select 6
union all select 8

declare @row int
declare cur_tmp cursor for
select distinct row from tbtest
open cur_tmp
fetch next from cur_tmp into @row
while @@fetch_status=0
begin
print @row
fetch next from cur_tmp into @row
end
close cur_tmp
deallocate cur_tmp
  相关解决方案