millsy007 Posted December 28, 2009 Share Posted December 28, 2009 Hi, I want to delete the contents of my table so that when I add a new row after my auto increment index starts again at 1, how do I achieve this? Quote Link to comment https://forums.phpfreaks.com/topic/186517-deleting-table-contents/ Share on other sites More sharing options...
rajivgonsalves Posted December 28, 2009 Share Posted December 28, 2009 use truncate TRUNCATE TABLE tablename Quote Link to comment https://forums.phpfreaks.com/topic/186517-deleting-table-contents/#findComment-985003 Share on other sites More sharing options...
Gamic Posted December 30, 2009 Share Posted December 30, 2009 Just for completeness: Sometimes you will not be able to truncate the table because there are foreign key constraints. In these cases you could either drop and create the table, or delete and reset the seed: DELETE FROM tableName; DBCC CHECKIDENT('tableName', RESEED, 0); [/Code] Quote Link to comment https://forums.phpfreaks.com/topic/186517-deleting-table-contents/#findComment-985961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.