• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

How do I set a start auto number for a sql server table

I have a table that has a n INT column that is used as a unique id, i was curious how I could have that column start at a number like 300,000 for example instead of defaulting to 1 when there is no data in teh table?


Thanks!

Loren
0
LTY83
Asked:
LTY83
  • 4
  • 3
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
DBCC CHECKIDENT (urColumn, RESEED, 300000)
0
 
LTY83Author Commented:
should I run that in query analyzer?
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
yes
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LTY83Author Commented:
what would the full statement look like? DBCC CHECKIDENT(mytable.mycolumn, RESEED, 300000) ?
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
this is the exact statement
ohh Sorry one typo error ....


DBCC CHECKIDENT (MyTable , RESEED, 300000)    --------- only table name is needed since only one identity column per table

0
 
LTY83Author Commented:
ahh i see, thanks!
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
sorry for my first mistake.. Its 11.44 pm here .. need a good sleep :)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
just 1 note (points for aneeshattingal):
when you create the table, you can specify the identity seed:

create table mytable ( identity_field int identity(300000, 1), <other fields> )

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now