declare @chid int DECLARE chCursor CURSOR --定义游标 FOR (select ID from ChooseSubject where ID in (select * from SplitToTable(@chList))) order by id --查出需要的集合放到游标中 OPEN chCursor; --打开游标 FETCH NEXT FROM chCursor into @chid; --读取第一行数据 WHILE @@FETCH_STATUS = 0 BEGIN print @chid FETCH NEXT FROM chCursor into @chid; --读取下一行数据 END CLOSE chCursor; --关闭游标 DEALLOCATE chCursor; --释放游标