用IDENTITY函数,样例:
CREATE TABLE jobs
(
   job_id  smallint
      IDENTITY(1,1)
      PRIMARY KEY CLUSTERED
 )

解决方案 »

  1.   

    好,谢谢。。俺学艺不精啊看着MSDE文档都没看到,汗一个大的
      

  2.   

    For your infromation:-)
    是stored procedurecreate table tt (n nvarchar(10))
    insert into tt select 'a' union all select 'b' union all select 'c' union all select 'd'
    go
    select * from tt
    go
    create proc d
    @id int
    as
        declare @bh int
        set @bh=@id
        exec('select identity(int,'+@bh+',1) id,* into #t from tt select * from #t drop table #t')
    go
    exec d 10
    go
    drop proc d
    drop table tt