How to change column id increment

The following statement may reset seed

DBCC CHECKIDENT ('TableName', RESEED, 1)

but this time I need to change its increment.

+3
source share
3 answers

Or you can use Sql Server Management Studio:

Identity Increment in Sql Server Management Studio

Using this approach is likely to recreate the table.

+1
source

Hope this helps

 ALTER TABLE MyCustomers 
 ALTER COLUMN CustId IDENTITY (200, 2)

Code from ms-help: //MS.VSCC.v90/MS.MSDNQTR.v90.en/ssmprog3/html/5719d3e4-14db-4073-bed7-d08f39416a39.htm

0
source

, 2 . - IDENTITY (1,2) . , script .

Let TableA be our actual table.

  • CREATE TABLE TableB (col1 INT IDENTITY (1,2) NOT NULL, col2 VARCHAR (10) NULL);
  • INSERT INTO TableB SELECT col2 FROM TableA;
  • TABLE DROP TableA;
  • sp_rename TableB, TableA;
0
source

Source: https://habr.com/ru/post/1707843/


All Articles