因为你这种可能循环啊游标随排序后可以自动退出
ALTER PROCEDURE ichoice  --多项选择题
    -- Add the parameters for the stored procedure here
      
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;    -- Insert statements for procedure here
    declare @total int --, @t int
    set @total = 0
--    set @t = 0
    create table #result( subjectid nvarchar(20) null,
                          tigan nvarchar(4000) null,
                          id2 varchar(53) null,
                          optionid varchar(50) null,
                          optioncontent varchar(255) null,
                          rightkey varchar(53) null,
                         )    while @total < 80
    BEGIN
        SELECT T.subjectid, T.tigan,X.id2, X.optionid, X.optioncontent,X.rightkey
        into #itmp
           FROM (SELECT TOP (1) subjectid, tigan 
                   FROM 题干 
                   ORDER BY NEWID()) AS T INNER JOIN 
               选项 AS X ON T.subjectid = X .subjectid 
              ORDER BY T.subjectid , X .id2,X.optionid  --      set @t = (select count(*) from #itmp)
        set @total = @total + @@rowcount--        if @total > 80
--        begin
--            set @total = @total - @t                
--        end        if @total <= 80
--        begin
            insert into #result select * from #itmp                
--        end
else
            set @total = @total - @t        DROP table #itmp 
            END
    
    select * from #resultEND