怎么写存储过程生成一批连续的数据,请高手指点。一点思路都没有。

解决方案 »

  1.   

    ????????
    select top 1000 id=identit(int,1,1) from sysobjects a join sysobjects b on 1=1 join sysobjects c on 1=1
      

  2.   

    不行啊,报错误: 仅当 SELECT 语句中有 INTO 子句时,才能使用 IDENTITY 函数。
      

  3.   

    那你就加into呀
    select top 1000 id=identit(int,1,1) into # from sysobjects a join sysobjects b on 1=1 join sysobjects c on 1=1
    select * from #
      

  4.   

    0--999
    select id=100*a.id+10*b.id+c.id from
    (select id=1 union select 2 union select 3 union select 4 union select 5 
    union select 6 union select 7 union select 8 union select 9 union select 0) a join
    (select id=1 union select 2 union select 3 union select 4 union select 5 
    union select 6 union select 7 union select 8 union select 9 union select 0) b  on 1=1 join
    (select id=1 union select 2 union select 3 union select 4 union select 5 
    union select 6 union select 7 union select 8 union select 9 union select 0) c on 1=1
    order by 100*a.id+10*b.id+c.id
      

  5.   

    不好意思,刚才没贴表结构出来。
    CREATE TABLE tbl_1015700128_VIRTUALTEL
    (
    VirtualTel   VARCHAR(20) NOT NULL,                     
    TrueTel            VARCHAR(20),                              
    ActiveFlag                numeric(3) DEFAULT 0,                   
    CallerState               numeric(3) DEFAULT 0,                    
    CalleeState               numeric(3) DEFAULT 0,                      CreateDate              datetime,                                
    BindDate                  datetime,                                UnbindDate                datetime,
    CONSTRAINT PK_VIRTUALTEL3 PRIMARY KEY(VirtualTel)
    );
    要生成一批连续的VirtualTel,怎么做啊?