请问如何实现创建一个可以实现里面的数据自动增加的sql server表,实现当取出里面的数据后,该数据自动加1,之后再取的话,就是加一后的数据。

解决方案 »

  1.   

    create table tb(id int identity , val int)
      

  2.   

    create table tb(id int identity , val int)
      

  3.   

    我就要一个值,取出来之后,自动更新为原值加1----自增列已经能满足你的需求.或者select isnull(max(id),0) + 1 from tb
      

  4.   


    create table #(id int)
    insert # select 0
    godeclare @id int
    update # set @id=id=id+1
    select @id -->1
    godeclare @id int
    update # set @id=id=id+1
    select @id -->2
    godrop table #