SQL Server 2008 How to add a self-added column to implement the self-added serial number _mssql2008

Source: Internet
Author: User
In the "Computer room toll system", some tables need to add their own columns, add a new record automatically add a serial number. Here are two ways to add:

One, through T-SQL code.
Copy Code code as follows:

ALTER TABLE name add column name int IDENTITY (1,1) not NULL

Here we use the Identity keyword: indentity (a,b), a B are all positive integers, A is the start, B is the step, indentity (1,1) on behalf of 1, each increase 1

Second, through Enterprise Manager

Open Object Explorer, create a new table, as shown below

Inserts a column, sets the column properties, identifies the increment as the step, identifies the seed as the starting number, and the following figure

The beginner, the improper place please criticize correct!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.