February 27, 2004 at 2:47 pm
Sorry probably been asked a thousand times, i tried a search on this forum and couldn't find it so
I have a database with a int auto increment primary field, all of the data has been deleted. How do i reset the auto increment field back to 1?
Thanks
February 27, 2004 at 2:50 pm
DBCC CHECKIDENT (TableName , RESEED, 0)
* Noel
February 27, 2004 at 3:04 pm
truncating the table has the same effect
set nocount on
if object_id('idt') is not null
drop table idt
go
create table idt(
col1 int identity(1,1) primary key )
go
insert into idt default values
select * from idt
truncate table idt
insert into idt default values
select * from idt
set nocount off
col1
-----------
1
col1
-----------
1
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
February 28, 2004 at 2:04 pm
Excellent! Thanks noeld & Frank for the fast replys
February 28, 2004 at 2:22 pm
No problem
Btw, there is no need to excuse to asking a question, methinks. There is only a need to excuse for a bad answer.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply