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 2008 Forums
 Transact-SQL (2008)
 delete table is it possible to reset the identity

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-03-31 : 11:26:03
I want to run a delete statement on a table, is it possible to reset the idenetity column.

Delete from Tab_EmailActivities

Thank you very much for the helpful info.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-31 : 11:41:22
yes
see http://msdn.microsoft.com/en-us/library/ms176057.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2011-03-31 : 16:51:49
If appropriate, a TRUNCATE TABLE operation will also reset the identity to its Seed value.

=======================================
Elitism is the slur directed at merit by mediocrity. -Sydney J. Harris, journalist (1917-1986)
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-04-01 : 05:03:39
DBCC CHECKIDENT (yourtablename, reseed, 1)



--------------------------
http://connectsql.blogspot.com/
Go to Top of Page
   

- Advertisement -