Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to reset identity from IdPatient column

Author  Topic 

mihaispr
Starting Member

3 Posts

Posted - 2009-11-11 : 17:31:08
I have created a table with create table command:


CREATE TABLE Patients
(IdPatient int PRIMARY KEY NOT NULL IDENTITY(1,1)
column2 type
column3 type
etc.
)



How I can reset identity (auto-incrementation) for column IdPatient?

I tried that:



ALTER TABLE Patients
ALTER COLUMN IDpatient IDENTITY(1,1) -- so my question is how to reset identity(auto-incrementation) in a query


Any ideas please?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-11-11 : 18:22:36
To reset it:
DBCC CHECKIDENT ("TableName");

To set it:
DBCC CHECKIDENT ("TableName", RESEED, 30); -- Sets the current seed value to 30
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-12 : 01:38:01
If you use identity column, you should not worry about having gaps

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -