Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server & have generously sponsored dedicated servers and web hosting to ensure a reliable and scalable dedicated hosting solution for

Reset Auto-Id

Can I reset the Auto_ID column in a table to start from 1 again?


View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Primary Key Auto-increment Reset
Ok - I have two tables that are relational. I have been inserted data into the tables because of testing. I also have been deleting data. My question is how do I reset the auto-incremented Primary key values.
For example:
Primary key of table one is bizID. Well there are only 3 record currently in the table. The bizIDs are 1-3. If I insert another record the bizID will be 88 because that was the next auto-incremented number. I obviously deleted the other records. I want to start the primary key value over from zero. How do I accomplish this? thnks

View Replies !   View Related
Primary Key Auto-increment Reset
I'm still looking for a solution on msdn, but i've decided also to post my question here.

How can i reset my primary key field auto-increment back to 0 in runtime (or in designtime)?

View Replies !   View Related
Reset The Auto Increment Columns In MSDE
Can Ne1 tell me how to reset the auto increment colum of a table in the Microsoft Data Engine??, Does ne1 know where to find a free MSDE administration utility.

View Replies !   View Related
Ssrs - Auto Time And Auto Updates In Report
My report in SSRS does update only when i run that
query in MS access. I migrate the 97 database to 2003
ms access database. I imported that report in ssrs
using import tool in ssrs. i have set up shared data
sources using odbc connection to ms access database.
auto refresh works only when i manually run query in
ms access.

Here's my has several table.

SELECT Call_Completed_by_Engineer_Daily.FullName,
Call_Completed_by_Engineer_Daily.[Remaining Calls],
Call_Completed_by_Engineer_Daily.[Fairfax Calls],
Call_Completed_by_Engineer_Daily.[SystemS Calls],
Call_Completed_by_Engineer_Daily.[AACPS Calls],
Call_Completed_by_Engineer_Daily.[NSN Calls],
Call_Completed_by_Engineer_Daily.[MVA Calls],
Call_Completed_by_Engineer_Daily.[Other Calls],
Call_Completed_by_Engineer_Daily.[Total Calls],
Call_Completed_by_Engineer_Daily.[All Tech],
FROM Call_Completed_by_Engineer_Daily
WHERE (((Call_Completed_by_Engineer_Daily.FullName)
Not Like 'Jim Rowland*' And
(Call_Completed_by_Engineer_Daily.FullName) Not Like
'Bill Bockmiller*' And
(Call_Completed_by_Engineer_Daily.FullName) Not Like
'Hong Nguyen*' And
(Call_Completed_by_Engineer_Daily.FullName) Not Like
'Hossein Talaei*' And
(Call_Completed_by_Engineer_Daily.FullName) Not Like
'James Hawkins*' And
(Call_Completed_by_Engineer_Daily.FullName) Not Like
'Joe Cooley*' And
(Call_Completed_by_Engineer_Daily.FullName) Not Like
'Peter Threatt*'));

This is a final query that i am getting report from.
They are other queries that grab the information from
table. For example, FullName query - Remaining Calls -
Fairfax Calls......

FullName Remaining Calls Fairfax Calls SystemS Calls
AACPS Calls NSN Calls MVA Calls Other Calls Total
Calls All Tech Department
Jay Brittain 10 4 4 JB DC
Jeremy Ditto 2 2 1 3 JD DC
Jing Kenny Hu 8 1 1 1 3 JKH DC
Phone Soe 11 1 2 3 PS DC

This is datasheet view of that query.

I imported access report to sql reporting service. i
can see it that report in web server too. However, i
have to hit refresh every time. Can you tell me where
to set up time?

i want autorefresh time with all auto updates information.

can anybody tell me plz?

View Replies !   View Related
Auto Increment Auto Non-identity Field
I have an MS SQL Server table with a Job Number field I need this field to start at a certain number then auto increment from there. Is there a way to do this programatically or within MSDE?

Thanks, Justin.

View Replies !   View Related
Auto Close And Auto Shrink
what is Auto Close and Auto Shrink used for?
these can be used for large web sites? like portal?

View Replies !   View Related
Can I Reset Tbl ID To 1
I have a table in my db that has an identity column as the primary key. I have deleted all the data and have tried to use truncate table on it to reset the identity column. The table has a number of foreign key constraints so it will not truncate.
Is there any way to reset the indentity column without removing the constraints?

View Replies !   View Related
How ASP.NET 2.0 Be Reset, Thanks.
Hi, I know the subject doesn't tell anything.I am troubleshooting my SQL cache dependency, it doesn't work as it should, Iposted question about it several times but didn't get an answer. In simple, I set up SQL 2005 cache as every article told but my cached items didn't be cleared after I modified table record. I am trying to figure out the problem, I have a static class, it has a static variable, like namespace MyLibrary{  public static class MySites  {         public static string _cacheLog = "";     ....when an cached item is removed from HttpContext.Current.Cache, a message and removed reason will be added to _cacheLog, when I refresh page, I will display _cacheLog on page. It is not a good solution, but I think it should work. But I found after a while, the variable is cleared, seems like the IIS instance is reset, any idea on this?Thanks! 

View Replies !   View Related
UDF Does Not 'reset'

FUNCTION [dbo].[fn_concat_boxes](@item varchar(10), @week int, @type char(1))

DECLARE @Output varchar(100)

SELECT @Output = COALESCE(@Output + '/', '') +
CAST(quantity AS varchar(5))
FROM flexing_stock_transactions
WHERE item = @item AND week = @week AND firm_or_commission = @type
GROUP BY quantity
ORDER BY quantity

RETURN @Output


gives the same output every time it is called, despite different parameters passed. @Output does not change as expected.

Any ideas guys?

View Replies !   View Related
Can I Reset Identity?
I have a table where I delete all the records, then reload.  can I reset the identity to (1,1)  Is there a SQL command for that?

View Replies !   View Related
SQLDataSource Reset?
I have a SQL data source triggered with this code:  string searchstring = TextBox2.Text;
SqlDataSource1.SelectCommand = "mod_search_all_sel";
SqlDataSource1.SelectParameters.Add("search_str", searchstring);
SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure; The second time this fires however, the SelectParameters.Add function creates another paramter and the stored procedure blows up. How do I do a reset like in old Classic ASP where you would set the  DS = Nothing?   

View Replies !   View Related
Reset Pimary Key To 1
Hi Forum, I have a .mdf that I have used to test SQL data app. I want to reuse the .mdf; delete all added data and reset Customer_ID primary colomn back to 1. All good info appreciated thanks Paul

View Replies !   View Related
Reset Id Field
I have a few SQL tables that use an auto incrementing integer key field, ie it has 'is identify' set to yes
The tables have been used for testing while the application was developed.
I plan to delete all data from these tables when the application goes live.  Is there a way to start SQL counting from 1 again without deleting and re-creating thr tables?

View Replies !   View Related
Priority Reset
consider my table,           priority          status
1                2                  pending
2                3                  pending
3                0                  completed
4                1                  pending
5                0                  completed
 Now, if I insert a record as,
6                1                   pending
the priority must be reset as follows,           priority          status
1                3                  pending
2                4                  pending
3                0                  completed
4                2                  pending
5                0                  completed
6                1                  pending
Im using c# and sql server. How can i do it?

View Replies !   View Related
How To Reset Identity ?
In my application , DB has a large table. I write a small program to clear the table whenever the size of table is over 50 MB. At that time , I want to reset identity as 1. How can I do that?
Currently , my program delete old table and generate a new one with the same schema when the table is too large.But this is kind of ugly.

View Replies !   View Related
ID Field Reset
This morning I made a change to two tables in my live system. All I did was add a new column in each called 'suspense' with a data type of bit and a default value of '0'.

When the users started using the system they noticed that the record ID numbers had reset and were starting from 1 and going up 2, 3, 4 etc. The last good id number was about 20500. The id columns are set as primary key with identity and increment of 1.

This shouldn't happen should it? Is it a bug? I never touched the ID column, just added the new one.

View Replies !   View Related
T-SQL Way To Reset Primary Key - Need For DTS
I have a DTS package that deletes all the records in a table and repopulates from an ACCESS table. All's well except the primary key of the target table doesn't go back to 1.

What's the syntax in T-SQL to accomplish that?

I imagine it's dropping the column and adding it back - but since it's a primary key field, regular drop/add syntax isn't working for me.

Any help here is appreciated.



View Replies !   View Related
Connection Reset
Hi all

I have build an application on top of SQL Server 2005 and i am using microsoft driver. My application stops periodically becoz of Database Connection Loss and I get the following exception An exception occurred during the DBComms.transmit operation. Exception:Socket closed. Context:(5) [Thread[Thread-55,5,main], IO:7e2dc, Dbc:null].
10:06:14:703 AM at keFromDriverError(Unknown Source)
10:06:14:703 AM at own Source)
10:06:14:703 AM at Unknown Source)
10:06:14:703 AM at ndExecute(Unknown Source)
10:06:14:703 AM at ExecuteQuery(Unknown Source)
10:06:14:703 AM at ement.executeQuery(Unknown Source)

Unable to find the exact reason for the above problem. Pl advice

Thanks & Rgds

View Replies !   View Related
Reset Indentity
How do reset identity seed on table, for example I have table that has gap in the identity such as (1,2,3,5,6, etc..) and I want reset the entire table.

Thank You,

View Replies !   View Related
Reset Identity?
Can a column of Identity type reset after it reaches its maximum value?


View Replies !   View Related
Hello everyone:

this procedure resets the business day to one for every month. It works fine except for the month of October. any idea or suggestions?

SET @i = 1
-- LASTDAY is the last day of the month
-- the counter will reset to 1 on the first of each month
WHERE WkDayIn = 'Yes' AND HolidIn = 'No'
-- update the business day in D_DATE
SET BusDay = @i
WHERE DateID = @DateID
-- reset the counter to 1 if it's the last day of the month
SET @i = 1
SET @i = @i + 1

View Replies !   View Related
Hello All:

i am inserting a counter from a procedure based on the year/month.

I would like to reset the counter to 1 every month.

example of data:

count year/month


21200712 this counter should be reset to 1


SET @i = 1

WHERE WkDayIn = 'Yes' AND HolidIn = 'No'

SET BusDay = @i
WHERE DateID = @DateID
SET @i = @i + 1

Thank You

View Replies !   View Related
Reset SA Password
Hi experts, I would like to ask if there is a way to reset the SA password of SQL 2005 without having to know the current password?

Im using SQL 2005 Express


View Replies !   View Related
How To Reset A Table?
Hi to all,
I'd like to know how reset a table, that is I've build an applicationa with VB express, added a DataBase (DB.mdf) and created a table. Inthis program I add and remove records to the table. There is also a Primary Key (auto-increment).
I'd like to know how I can reset the table, that is delete all record and restart from 1 the primary key.


View Replies !   View Related
I want a reset-button which clear my formular....

I have the following code in mypage.aspx.vb:

Sub Reset(ByVal sender As Object, ByVal e As System.EventArgs)

Me.Server.Transfer("Mypage.aspx") 'reloads the page without postback?

End Sub

And a button on mypage.aspx:

<asp:Button ID="Button2" OnClick="Reset" runat="server" Text="Rensa" />

But when I click the button....the validation-controls executes instead for "clearing" the page (reload it without postback) the validation-messages shows that I have forgott to write in som textboxes....

What should I do?

View Replies !   View Related
Does Any One Know How To Reset Sa Account?
I'm a programm designer, when using SQL Express Server,
one of my codesigner accidently changed the name of sysadmin account "sa" into somthing else, even disabled the login of this account.

since that's the only one account we can login, the database is now closed to any further operation above basic level.

looking for any possiable means to regain the control of database. 

like how to reset "sa" account or reset the "master" database.

we sure make a "security database now" *_*

View Replies !   View Related
How To Reset A Database
We are about the deploy our project. We made many testing such as Random data insertion etc. Some tables have autoincrement column, and their numbers reached3,000,000. After testing, we delete all data in database. Now question is how can we truncate all tables, and make fresh start. We may use TRUNCATE query but it is boring and giving errors some time. Is there way to reset whole database, and make a fresh start, like no data entered before.????

Thanks for help, Happy Coding

View Replies !   View Related
Regarding this post:

This could be the follow up of that post, but I thought it would be a good idea to open a new post to discuss the ReportViewer.Reset() method.

This is the background:I was getting a "Execution '' not found" error when generating reports, VDeepak wrote something about ReportViewer.Reset() as a solution for this, so I tried with it.

At my workstation, running the project with VS2005 it worked flawlessly. Nevertheless, when I updated the files on the server I got an exception: "method ReportViewer.Reset() not found". Apparently, this was because of an outdated dll: Microsoft.ReportViewer.WebForms.dll. In other post, somebody told this could be solved installing the SQL Server 2005 SP1, I did it with no success... I found a SP2 was launched recently, so I downloaded installed it... Now another exception: a "http bad request exception". Desperate, I removed the ReportViewer.Reset() line from the code and uploaded the files to the server again. This time, everything went ok again, actually, I havn't found the freaking "execution '' not found" exception.

There are two questions here:

1 - What exactly does ReportViewer.Reset() method do? and why the same code could be failing on the server when it was working ok in the workstation (believe me, I tried everything, the only diference is this method).
2 - By chance, could the "Execution '' not found" error be fixed with the SP2??? I searched the change log and found nothing about it.


View Replies !   View Related
Reset Tables
use Microsoft SQL Server and also I have several tables. One table has
ID like PK, and name. ID use autoincrement number mode, and now when I
want start form one but not from 156 or like that. I don't know how?
And also when I delete all data from table an run my apllication and
add something in table, it starts form last number, not from one.

Maybe can I do it from SQL menagement studio?

How I can reset table and start from 1?

View Replies !   View Related
Sorry if this is a dumb question, but I am new to SQL Server and trying a simple cursor. Works fine the first time I execute, but then @@Fetch_Status stays at -1 and it will not work again. If I disconnect and then connect it will work once again. What I am doing wrong?

declare @entityid int, @datafrom nvarchar (255),

@datato nvarchar (255), @updatedate datetime

declare statustime1 cursor

local scroll static


select audit.entityid, audit.datafrom, audit.datato, audit.updatedate

from audit

, orders

where audit.entityid = orders.orderid

and audit.entitytypeid = 4

order by orders.orderid, audit.updatedate desc

open statustime1

While @@fetch_status = 0


fetch next from statustime1

into @entityid, @datafrom, @datato, @updatedate

print @entityid


close statustime1

deallocate statustime1


View Replies !   View Related
Reset A Database
I have red this thread while I was searching an answer to my problem. Basically when you develop an app. you do some testing to check if everything is fine. When the testing is done you have primary key seeds starting from a number x which is not 1, as it is when the db is newly created.
I read about the truncate instruction (which I knew from mysql) but I can't perform the query because of the presence of a foreign key constraint in another table.

So I thought, maybe there is a way to tell the DB engine to disable FK checks while I do the truncation, but I can't find it in the documentation.

So the question is: using SQL EXPRESS what is the quickest way to reset the db state to its initial state, where all the primary key seeds were 1?

thanks in advance and sry if this question is already answered somewhere else, I searched but I didn't find a solution.


View Replies !   View Related
How To Reset The Values In Id Column?
Hi,i m using vwd2005 express and sql express.i've created a table in sql express and set id fied to primary key and set identity to when i add a record a the id is auto generated this way 1,2,3,4....but when i delete these records and add the new record.the id column now adds a new id as 5 then 6,7 etc.but i want the id to generate from 1,2,3 can this be done?any idea?thanks. jack. 

View Replies !   View Related
Deletion And Identity Reset
Obviously to delete all records from DB table is simple, however, I would like to make my whole Live DB pretty much empty.  I've copied all my data from my test DB over to my live DB (didn't mean to but I did).  I would like to remove all the data and the identity values, resetting them back at their original values.  Is there a simple way or do I have to do it the hard way.  That being going in and removing Identity, saving and then placing identity back on the DB Table.

View Replies !   View Related

Can I reset the IDENTITY seed of a Table column without delete/drop the table?

I want to delete all the table rows, restore de seed, and restore a
backup made on a XML (using SET  IDENTITY_INSERT Table ON)

I cant drop the table due to acount restricctions.


View Replies !   View Related
Reset Identity DataType
How can I reset an identity Int column back to start with 1 if I remove all rows from the table?


View Replies !   View Related
Reset The Identity Increment
Reset the Identity IncrementHello:I have a table with a bigint type column (field) that has an identity seedof 1 and an identity increment of 1. The column is the primary key for thetable.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 1automatically. (start counting at 1 again). How does one do that, becauseas it is now, the DB keeps increasing the value of the column from where itleft off, regardless of the fact that I deleted all of the data in thetable.The DB is MS SQL Server 2000.Thanks and appreciate any help.Ryan Kennedy

View Replies !   View Related
Reset Msde Sa Password
I have installed msde 7.0 on a pc with win98.Someone has changed sa passwordHow can I reset sa password?I'm unable to logon with trusted connection because the pc is not nt.Thanks

View Replies !   View Related
Reset Identity Seed
I would like to set the identity seed to a different value. How do I do that? Please help!


View Replies !   View Related
Can You Reset An IDENTITY Column?
I accidentally inserted a ton of error records into a table that contains an identity column and now after removing the error records, my IDENTITY column numbering is way off! My last correct record has an IDENTITY number of 4225, if I insert a new record the IDENTITY of that record will be 77935.

Is there any way to reset the numbering of this column so that the next record I insert will get an autonumber of 4226?

Thanks for any info. or help with this...


P.S. After this error, I now make sure I use BEGIN TRANSACTION before running ANY SQL commands, this way I can always ROLLBACK if I see a major problem happening like what happened here...

View Replies !   View Related
Reset Administrator&#39;s Password
i have one prod server and one standby i would like to have same logins on both can some one tell me how to update syslogins table in same order as source

View Replies !   View Related
Job Fails, How Do I Reset Circle With Red X
When a job fails, the right pane of EM for Jobs show a circle with a red X to the left
of the job. Thus making it easy to find problems.

Is there a way to reset the job to a status that eliminates the circle with the red X,
without successfully reruning the job?


View Replies !   View Related
Automatically Reset SQL Server
Hi all,
I am wondering if there is a way that the SQL server resets every few hours. I am using an application which is heavily utilising SQL server and the server crashes every now and then. I can reset it manually but I was wondering if there is a way that it detects the crash and reset itself automatically. Thanks a million in advance.

View Replies !   View Related
Reset The Primary Key Number To 1
Hi all... how to reset the primary key to 1?


"I won't last a day without SQL"

View Replies !   View Related
Reset Autonumber Primary Key
Ho wdo i do this? when i delete records and then post a new one from the start I want that to be number 1? I am using MSSQL

View Replies !   View Related
Reset Key Field To 1 RESOLVED
I have test tables with key fields that increment by one each time a record is added. If I delete all the records in a table (using a delete query) is there a way I can make the key start at 1 again.

The reason I ask is that by using test data in these tables (and there are a lot of records),when I clear them out and append the live data the key field starts at something like 764525

View Replies !   View Related
Identity Set , How To Reset Record No
i have a table with the following fiels ,
Column NameDataType
Sno intIdentity = Yes , Identity Speed =1 , Identity Increament =1

Now i entered data and coneected to database, worked.Now after cheking all the data entered with the form , now i have to send the table to client place.
The problem is , the sno column has the value which i entered last. now if i delete all records , then also the record no doesnot become 0.
what i have to do, to set the sno column to 1 again.

View Replies !   View Related
Distribution Reset Automatically?
I'm a DBA, recently encounter one weird case.
I received an alert on distribution log file running out of space. Everytime, i increase the log file size, it reset back to in original one after several hours. Does anyone know what is going on?

Apprecaited if anyone can answer this.

Thank You.

Jimmy Liew

View Replies !   View Related

Copyright 2005-08, All rights reserved