• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • 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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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