I have a sql-database with one table and in the table there are now around 70 rows...
I wonder if its possible to "delete" or "remove" these rows so that the ID (the primary key) start to increase from 1 again....or am I forced to create a new table (and delete the one who exists now) to get the ID to increase from 1 again?....
hi,
try
truncate table <tablename>
regards,
joey
|||ok..but I just ment that I should do it in the visual web developer (which is the program I had) and just do it directly in the program (not with code)...I just wonder if its possible to do it...and how I do it if its possible....|||There is no other way to accomplish this task without running the t-sql on the table either in the vb.net/c# or through an analyzer.
Adamus
|||If you mean use the IDE, you can manually delete all records from the table. From the table definition, you delecte this id column first and recreate it and set it to identity column. It should get the seed to 1 again.|||Tigers21 wrote: I have a sql-database with one table and in the table there are now around 70 rows...
I wonder if its possible to "delete" or "remove" these rows so that the ID (the primary key) start to increase from 1 again....or am I forced to create a new table (and delete the one who exists now) to get the ID to increase from 1 again?....
Well you'll have to delete the rows, or you'll get a PK error, this script should do it for you:
truncate table TableName
dbbc checkident('TableName', reseed, 0)
No comments:
Post a Comment