SQL利用游标读取列并执行操作
2010-07-09 14:57 飞逝心情 阅读(342) 评论(0) 编辑 收藏 举报declare @id int,@name varchar(20); declare @IDList varchar(5000) set @IDList='' declare cur cursor fast_forward for select ArticleID,Title from Article; open cur; fetch next from cur into @id,@name; while @@fetch_status=0 begin --做你要做的事 set @IDList=@IDList+' '+convert(varchar(10),@id) fetch next from cur into @id,@name; end close cur; deallocate cur; print @IDList