自己研究出来的第一个游标
create table #temp(ttype varchar(50),tno int)
declare @temp_type1 varchar(50)
declare @temp_type2 varchar(50)
declare @temp_no int
declare mycursor cursor for select imagetype,imageno from imageproperty_t where archno='141227'order by imageno
open mycursor
fetch next from mycursor into @temp_type1,@temp_no
set @temp_type2=@temp_type1
insert into #temp values(@temp_type1,@temp_no)
while(@@fetch_status=0)
begin
if @temp_type1<>@temp_type2
insert into #temp values(@temp_type1,@temp_no)
set @temp_type2=@temp_type1
fetch next from mycursor into @temp_type1,@temp_no
end
close mycursor
select * from #temp order by tno