简单问题 ,请帮忙解决!谢谢
字段 : row (该字段数据不连续,有重复数据)
数据: 2
2
3
5
6
8
.....
如何把该字段的数据(不重复)依次取出来送给变量@row ?
------解决方案--------------------如果只是取出不重復的數據,這樣也可以
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