Re: Renumbering MS db ID?
From: William Ryan eMVP (dotnetguru_at_comcast.nospam.net)
Date: 08/16/04
- Next message: Paul Clement: "Re: Renumbering MS db ID?"
- Previous message: William Ryan eMVP: "Re: Renumbering MS db ID?"
- In reply to: Norman Yuan: "Re: Renumbering MS db ID?"
- Next in thread: Rebecca Riordan: "Re: Renumbering MS db ID?"
- Reply: Rebecca Riordan: "Re: Renumbering MS db ID?"
- Reply: Terry Kreft: "Re: Renumbering MS db ID?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 15 Aug 2004 23:42:49 -0400
Norman:
I'm not an Access user, but as far as the notion that 'there is no need to
care what the ID field's value is', at least with SQL Server I can think of
more than a few instances where this wouldn't be the case - it really
depends on the app requirements don't you think?. You can use for instance
TinyInt, SmallInt, BigInt, Numeric, Decimal etc. If you had a lot of
deletions and a scenario where you'd never have more than say 100 items in
a given table, you could safely specify the use of a TinyInt value and just
recycle things. If this was a pretty volatile table you could easily go
over 255 necessitating the use of another datatype. We do this currently
with our employee badge system and since the license comes in one block of
100, then 700 then 1000 - recycling the ones makes a lot of sense. I've
also seen a few implementation where they used identity fields to count
concurrent users for licensing purposes and reusing those values was used to
facilitate this counting. I'd agree it's easy enough to use int instead of
tinyint and implement a different scheme for concurrency tracking, but in
those instances it was a fairly straightfoward way to accomplish the tasks.
Similiary if your app is such that you can keep everything sequential, it
would lend itself a little better to iteration and the like. Again not a
big deal and certainly something you could do without, but not necessarily
something I'd write off entirely.
Cheers,
Bill
-- W.G. Ryan MVP Windows - Embedded Have an opinion on the effectiveness of Microsoft Embedded newsgroups? Let Microsoft know! https://www.windowsembeddedeval.com/community/newsgroups "Norman Yuan" <nobody@nowhere.no> wrote in message news:e%23xsTxugEHA.704@TK2MSFTNGP09.phx.gbl... > What is the "MS db"? MS Access or MS SQL Server? > > If I understand you correctly, you use AutoNumber (MS Access), or > Identity(SQL Server) as ID field value. There is no need to care what the ID > field's value is, as long as it is unique in the table, autonumber/identity > guarrantees that and it is the only purpose autonumber is used for. If you > want the ID value in particular order, you have to roll out your own logic > to achieve that, and it is not an easy task to do. > > However, if you regularly delete every thing in the table and really want > the new record's ID starting fro 1, you can compact the database after > deleting, if you use Access DB (there is also a way to do it in SQL Server > to re-seed the idetity field, I believe, but, why bother?). > > "Mr. B" <User@NoWhere.com> wrote in message > news:1n3vh05bjp07gmapaq1rfr4u7b92l81hsr@4ax.com... > > I have a small MS db which I update daily with new info. I've noticed > that > > the ID numbers are increasing sequentially. How can I reset them back to > 1 > > when I purge my data prior to adding in the new stuff? > > > > Here is how I'm currently deleting the info from my db (TSUpdate): > > > > > > Private Sub ClearMyData() > > ' Open Connection and Clear Data > > OleDbConnection1.Open() > > Dim MyCommand As New OleDbCommand("DELETE FROM TSUpdate", > > OleDbConnection1) > > MyCommand.ExecuteNonQuery() > > OleDbConnection1.Close() > > MyCommand.Dispose() > > End Sub > > > > > > Thanks in advance! > > > > Bruce > >
- Next message: Paul Clement: "Re: Renumbering MS db ID?"
- Previous message: William Ryan eMVP: "Re: Renumbering MS db ID?"
- In reply to: Norman Yuan: "Re: Renumbering MS db ID?"
- Next in thread: Rebecca Riordan: "Re: Renumbering MS db ID?"
- Reply: Rebecca Riordan: "Re: Renumbering MS db ID?"
- Reply: Terry Kreft: "Re: Renumbering MS db ID?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|