473,726 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reset Primary ID back to 1

1 New Member
Reset the Identity Increment
--------------------------------------------------------------------------------

Reset the Identity Increment


Hello:
I have a table with a bigint type column (field) that has an identity seed
of 1 and an identity increment of 1. The column is the primary key for the
table.

After I backup and clean out the database (delete all of the data in the DB)
I need to have the column with the identiy seed/increment value reset to 1
automatically. (start counting at 1 again). How does one do that, because
as it is now, the DB keeps increasing the value of the column from where it
left off, regardless of the fact that I deleted all of the data in the
table.

The DB is MS SQL Server 2000.


Thanks and appreciate any help.
Jun 4 '07 #1
2 8603
iburyak
1,017 Recognized Expert Top Contributor
The only way to do that is to use truncate table instead of delete.
You need additional rights to be able to execute truncate table statement.

Good Luck.

Irina.
Jun 4 '07 #2
jojo41300000
32 New Member
Yes, of course you can use truncate. It will delete and reseed the identity columns.
It is also more efficient way to save the resources.

But, if you also want to use delete, you can reset the identity column by running the following command:

DBCC CHECKIDENT('myt able', RESEED, 0) ;

Hope to help.
Jun 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2229
by: Graham Mattingley | last post by:
I have built a database with a Primary Key / Auto Increment. I have been doing loads of testing with adding and deleting records. Now I need to delete all of the test records, and put the database on a live website. Is there anyway to reset the Primary Key back to 1. Now when I have deleted all the records, the Primary Key uses the next number from when the records existed.
0
3724
by: Graham Mattingley | last post by:
I have built a database with a Primary Key / Auto Increment. I have been doing loads of testing with adding and deleting records. Now I need to delete all of the test records, and put the database on a live website. Is there anyway to reset the Primary Key back to 1. Now when I have deleted all the records, the Primary Key uses the next number from when the records existed.
12
23770
by: deko | last post by:
Is there a way to reset the AutoNumber sequence? I have several tables that use the AutoNumber field as the Primary Key, and I'd like to somehow do an Import/Export that will make remove the breaks in the sequence. A few breaks in sequence is not a big deal, but I have one table with under 200 records, but the last AutoNumber PK ID field is over 1500 - due to a lot of edits....
3
11239
by: trueblue7 | last post by:
I apologize if this question has been asked before... I'm trying to reset autonumber fields back to 1. The autonumber fields are part of the composite primary keys. I followed the MS help with a temp table and append query. I can change the number to anything but 1. I'm using Access XP and saving as 2000. Any help is appreciated.
4
10987
by: Chris Lane | last post by:
Hi, I have an HTML RESET button and Web Control Button that posts back to the server. Problem is the reset button doesn't work after the postback occurs. Any ideas or suggestions as to why this happens or how I can work around this? Thanks
11
6189
by: cansnowboard | last post by:
I built a file management database which generates a file number based on the year. i.e. 2006-PRRS-13 The criteria was that each file should be unique. So I took the primary key, added one to it and moved on. Several months down the road they came back and said did we mention the file number needs to reset to zero each year. They click a button to generate the file number.
11
7418
by: newbie | last post by:
i have a form in which a hidden field (initial value as '0', and my javascript set it to '1' when an event is trigged). In the same form, i have a reset field. But I realized that the hidden field is not reset to '0' when i push the reset button. If I simply change the node from "<input type="hidden" id='IsChanged' value='0'>" to "<input type="text" id='IsChanged' value='0'>" Everything is working as expected (the value is reset to '0'...
2
2701
by: ilany | last post by:
Hi to all.. The relationships in my database depend on autonumbered primary keys. Occasionally access will crash, causing all primary key values to be reset in tables. Now that the primary keys are rest, the table relationships are no longer valid. Example: For two tables, Suppliers, and Addresses In Addresses the promary key is AddressID.
2
1329
jmoudy77
by: jmoudy77 | last post by:
Hi, I've got a database with front-ends at multiple locations that pull from a primary back-end over a satellite network. Each time a front-end closes it triggers a back-up utility that creates a back-up of the primary back-end on that front-end's local network; so that in the event the link is lost to the primary back-end, that location's will automatically connect to the back-up back-end. Confused yet, good me too. My delima is that when...
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.