我们知道:
select 1
会返回一个1行1列的结果集,其值为1
(执行结果 “消息”为:1行受影响)我想有没有一条简单的sql语句,不需要查询任何表的,结果集为:1
2
3
4
(执行结果 “消息”为:4行受影响)谢谢。

解决方案 »

  1.   

    select '1' +char(13)+'2'+char(13)+'3'--试一下
      

  2.   

    select 1 union all select 2 union all select 3 union all select 4
      

  3.   

    ms还是在一行显示print '1'+char(10)+char(13)+'2'这个可以吗?
      

  4.   

    select 1 union all select 2 union all select 3 union all select 4
      

  5.   

    select 1 
    union all 
    select 2 
    union all 
    select 3 
    union all 
    select 4
      

  6.   

    表里面有你想要的整数序列master..spt_values
      

  7.   

    select 1 
    union all 
    select 2 
    union all 
    select 3 
    union all 
    select 4
      

  8.   


    select * from master..spt_values where number between 1 and 4 and type='u'
      

  9.   


    select number from master..spt_values where number between 1 and 4 and type='p'
      

  10.   

    MSSQL2008及以上版本可以使用表值函数:
    select * from 
    (
    values
    (1),(2),(3),(4)
    ) as t1(id)-------------------
    id
    1
    2
    3
    4
      

  11.   

    -- 这个是1到100的,把100改成4就可以了。
    ;with t as(
      select 1 as dt
      union all
      select dt+1 from t
      where dt+1<=100
    ) select dt from t option(maxrecursion 0)