试试:
declare @i int
select @i=count(*) from 表
if @i<100
  begin
    select * from 表 union all select A,B from (select identity(int,1,1) rowid,'' A,'' B from sysobjects) temp where rowid<(100-@i)
  end
else
  select * from 表

解决方案 »

  1.   

    我还是把所有的源程序贴上来吧SELECT *
    INTO #table1
    FROM (SELECT DISTINCT khbh
            FROM xskd
            WHERE datediff(day, xkdate, getdate()) > skjx) bselect top 100 *  from
    (
    select khbh, type AS 类型, xkdh AS 单号, Summoney AS 欠款金额, 
                  OrderType
            FROM (SELECT khbh, '销售开单' AS type, xkdh AS xkdh, Summoney AS Summoney, 
                          2 AS OrderType
                    FROM xskd
                    WHERE datediff(day, xkdate, getdate()) > skjx
                               
                   ) AS t
            Union all
            Select top 100 99999,'','','','' from sysobjects a) as c
            Order by khbh,OrderType
             
    drop table #table1