change auto increment number sql server 2005

hi ,
i have a table that i want tht PK will start from 100
how can i do it ?

thanks ...
Tech_MenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
Declare column and start with 100
Example:
id_num int IDENTITY(100,1)


0
Tech_MenAuthor Commented:
the table is alerady exsist
0
Om PrakashCommented:
Example:
Create table testTable (id_num int primary key IDENTITY(100,1), username varchar(100))
insert into testTable values ('user1')
select * from testTable -- will have id_num as 100

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tech_MenAuthor Commented:
no no the table is in the db i just need to reset the PK he is in num 40 i want to change it to 100
0
rajvjaCommented:
If the table already exists,

dbcc checkident(tablename, reseed,100)

will start from 100.
0
Tech_MenAuthor Commented:
i deleted all the rows from it and i want the firsr row will start in 100
0
Tech_MenAuthor Commented:
i try it :
dbcc checkident(dbo.Orders, reseed,100)
not working :
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.


0
Om PrakashCommented:
If the table is already present then
Create a new column with identity & drop the existing column

alter table testTable add id_num2 int primary key IDENTITY(100,1)
select * from testTable -- will have additional column
0
rajvjaCommented:

SeT IDENTITY INSERT ON

and update table by changing the ident column value to new value
0
Tech_MenAuthor Commented:
i dont want to add new col
0
Om PrakashCommented:
DBCC CHECKIDENT (Orders, RESEED, 30)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tech_MenAuthor Commented:
i try this :
SeT IDENTITY INSERT ON
(dbo.Orders, reseed,100)
not working :
Incorrect syntax near the keyword 'IDENTITY'
0
rajvjaCommented:
0
Tech_MenAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.

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.