How to create sequence in SQL Server 2008

后端 未结 6 1442
执笔经年
执笔经年 2021-01-02 23:37

I am creating sequence in SQL Server with the following code. But it displays error as unknown object type. Please give a solution

Here\'s my code :

         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-03 00:19

    SQL Server 2008 can't create sequences, Sequence objects apply to SQL Server 2012 through current versions.

    https://msdn.microsoft.com/es-es/library/ff878091(v=sql.120).aspx

    You can use an IDENTITY in your table instead, for example:

    CREATE TABLE Person(
        Id int IDENTITY(1,1) NOT NULL PRIMARY KEY,
        Name varchar(255) NOT NULL
    );
    

    The starting value for IDENTITY is 1, and it will increment by 1 for each new record.

    http://www.w3schools.com/sql/sql_autoincrement.asp

提交回复
热议问题