Groups | Blog | Home
all groups > sql server programming > august 2003 >

sql server programming : INT and Identity behavior


Bent Lund
8/26/2003 11:54:20 PM


Hello, I am designing a database that communicates with a PLC.

I have a product-log with a primary key of type intgere which is a
Identity inctr 1.

The PLC kan only read integeres up to 65k. In other words i need to
reset the Identity before exeeding 65k.

This will not cause duplicates, as the records in this table is deleted
after the production cycle is completed.

Does the Identity automatically restart at 1, or do i have to handle
this in the procedures i use for addind data to the table.


Regards

Bent

*** Sent via Developersdex http://www.developersdex.com ***
Pavel Birioukov
8/27/2003 5:42:56 AM
you can also create the view on the table with
select your_field % 65536, ... from your_table
not to think about needing to restart the ID...
or computed field in the table... :)

[quoted text, click to view]
Does the Identity automatically restart at 1, or do i have
to handle
[quoted text, click to view]
Amy
8/27/2003 8:41:30 PM
Hi Bent,

If you use TRUNCATE TABLE to delete the records from your table, it will
also reset the identity.
If you use DELETE, you will have to reset the identity to the appropriate
value using the DBCC CHECKIDENT statement.
DBCC CHECKIDENT ('mytable', reseed, newvalue).
If you need to clear all records from your table, use the TRUNCATE
statement.
It is far more efficient than DELETE and produces much less logging.

HTH

[quoted text, click to view]

AddThis Social Bookmark Button