views:

154

answers:

5

Pretty newbie question. Thanks for helping.

+3  A: 

Take a look at this msdn post, the value from which you want to start your identity is called seed.

If you want to do it from the GUI, then you can select that column and in its properties, in the identity specification section look of the IsIdentity and set it to true, then look for Identity Seed and specify the value which ever you want, you can also specify the increment as well.

Mahesh Velaga
Thanks, this is the solution. "id int IDENTITY(1,1)". :D
Serg
+5  A: 

In SQL Server, when you declare the column as an IDENTITY column, you specify a seed and increment.

The seed value is the number to start from, the increment is the amount to increment for the next number.

In this example, you start with 100, incrementing by 1:

column INT NOT NULL IDENTITY (100, 1)

If you want to change it for an existing table (so new records start from a different range), use DBCC CHECKIDENT.

In this example, the table dbo.myTable will start with a new seed of 300:

DBCC CHECKIDENT ("dbo.myTable", RESEED, 300);
Oded
+2  A: 

For an existing table, use:

DBCC CHECKIDENT('TableName', RESEED, 0);

You would just substitute your starting number for the 0.

For a new table use:

CREATE TABLE [dbo].YourTableName(
[UID] [int] IDENTITY(1,1) NOT NULL,
       ...
 )

Where the 1,1 is the starting number and the increment.

Mark Brittingham
+1  A: 
DBCC CHECKIDENT (yourtable, reseed, 34)
Dustin Laine
+1  A: 

Use SET_IDENTITY_INSERT_ON to insert the number you want to start with, then turn it back off.

Dave Swersky
nifty solution.
Raj More