1. 在第一列显示行数
2. 如记录不满 N 条(假设N=5), 要补齐记录, 全部为空即可例: select ......字段1   字段2
  1      aaa
  2      bbb
  3      ccc   
  4      null
  5      null 
....谢谢!

解决方案 »

  1.   

    应该会自动为空的...显示为NULL
      

  2.   

    declare @n int,@b 
    select @b=COUNT(*) from tb
    set @n=5
    if(@b<=@n) 
    begin 
     insert into tb   values (@b+1,NULL)
     set @b=@b+1
     end
      

  3.   

    IDENTITY(INT ,1,1)仅当 SELECT 语句中有 INTO 子句时,才能使用 IDENTITY 函数。
      

  4.   

    原有数据:
    select * from table
    ------------------------
    name   deptid
    张三     01
    李四     02
    王五     03
    赵六     04
    周七     05
    想要的结果,假设只要五条: 
    select ????
    ------------------------
    id   name   deptid
     1   李四     02
     2   王五     03
     3   赵六     04
     4   null    null 
     5   null    null
    ....PS: 不用null,用空字符也行
     
      

  5.   

    估计一条sql 解决有难度
    select count(0)as sumcase sum>=5 then select top 5...else select *from.. union selet "".""...
      

  6.   

    declare @n int,@b 
    select @b=COUNT(*) from tb
    set @n=5
    if(@b<=@n) 
    begin 
     insert into tb   values (@b+1,'')
     set @b=@b+1
     end
      

  7.   

    declare @n int,@b 
    select @b=COUNT(*) from tb
    set @n=5
    if(@b<=@n) 
    begin 
     insert into tb   values (@b+1,'')
     set @b=@b+1
     end
      

  8.   

    不知道这样行不行--create table abc(aid char(10) not null primary key,aname char(20) null)
    --insert into abc values('1','a')
    --insert into abc values('2','b')
    --insert into abc values('3','c')
    --insert into abc values('4','d')
    --insert into abc values('5','e')
    select a.aid,b.aname 
    from 
    abc a,
    (
    select * from abc where aid in('1','2')--where后面加条件
    ) as b 
    where a.aid*=b.aid
    结果:
    aid        aname
    ---------- --------------------
    1          a                   
    2          b                   
    3          NULL
    4          NULL
    5          NULL(5 行受影响)