SQL Server batch rules modify field values

Source: Internet
Author: User

Recently there is a task, the database of more than 3,000 existing data from 800000 to start numbering, each increment of 1, so there are the following three solutions:

1, directly in the database manually one plus (you happy is good)

2. Add a database field, such as number, set the numbers field as the identity column, set the seed and increment, and then set the field to be non-identity column and modify the field type (int data type only) after saving the table automatically generated value.

3. Using Database statements (recommended)

DECLARE @number INT--Defines a variable @number
Set @number = 799999--Sets the value of the variable to the seed value minus 1
Update table name set field name [email protected],@[email protected]+1--Modify field values, set rules as needed

SQL Server batch rules modify field values

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.