原来Id开始值为1,我想把以后插入的值都从1000开始,用SQL语句实现,而不是手动改表

解决方案 »

  1.   

    试一试
    dbcc checkident (mytable, reseed, 999)没有验证过。
    参考
    Tips for SQL Server Identity Columns 
      

  2.   

    可以用
    You can reseed the indentity value, that is, to have the identity values reset or start at a new predefined value by using DBCC CHECKIDENT.  For example, if I have a table named MYTABLE and I want to reseed the indentity column to 30 I would execute the following:
    dbcc checkident (mytable, reseed, 30)
    If you wanted to reseed the table to start with an identity of 1 with the next insert then you would reseed the table's identity to 0.  The identity seed is what the value is currently at, meaning that the next value will increment the seed and use that.  However, one thing to keep in mind is that if you set the identity seed below values that you currently have in the table, that you will violate the indentity column's uniqueness constraint as soon as the values start to overlap.  The identity value will not just “skip” values that already exist in the table.