Deleting records creating holes in my database

Results 1 to 3 of 3

Thread: Deleting records creating holes in my database

  1. #1
    Join Date
    Dec 1969

    Default Deleting records creating holes in my database

    I&#039;m sure this is a common problem but no-one has seemed to mention it in simple tutorials I&#039;ve read about record deletion.<BR><BR>Whenever I delete a record, it leaves a gap, meaning that ID number will never be used again. When new records are added, the primary key ID field will always be one more than the highest ID number.<BR><BR>This creates problems in some areas of my website. For instance, one procedure chooses a random quote from our database by picking a random ID number and loading the record corresponding to that ID. But if the ID it chooses has been deleted, it returns nothing.<BR><BR>Is there a way to make new records &#039;fill in all the blanks&#039; in a database left empty by deleting?<BR><BR>Thanks All

  2. #2
    Join Date
    Dec 1969

    Default Have you checked

    I think they had an article on this --- or I read something in their forums...<BR><BR>What database are you using?

  3. #3
    Join Date
    Dec 1969

    Default RE: Have you checked

    I wrote a FAQ on selecting a random record from a table, which also works with holes.<BR><BR><BR>BTW, there&#039;s also a much easier way to retrieve a random record<BR><BR>[code language="T-SQL"]<BR>SELECT TOP 1 * FROM TheTable ORDER BY NewId()<BR>[/code]<BR><BR>maybe you can use this as well??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts