SQL Server 2005 - Refreshing indexes - Primary Key ?

  • SELECT [Record Number], [First Name], [Last Name], Title, Phone, [Date of Birth], Address, Street, City, [State-Province], [Postal Code], [E-Mail Address]

    FROM Sheet1

    ORDER BY [Last Name], [First Name]

    My Code is above Q: How do I refresh the primary ket [Record Number]

    as it won't let you use a number after it has been used once and then deleted... It confuses me the programmer and the end user of my database program too... like ALTER INDEX ??? or compact rebuild index but I want the data to remain safe!!

    SQL Server 2005 Express ED

    HELP!:hehe:

    Jeff

  • Reuse of a number has nothing to do with indexes. I'm guessing it's an identity column. Is that so?

    Why do you want to be able to reuse numbers that have been deleted?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I guess you're rithe an identity coulmn with primary key also...

    I have the seed at 1 and the autonumber at 1 and the user gets confused if say she deleted record number 67 then went back into the program at a later date and tried to use that same number (67) it says record number is not unique... (I have a trap in the program that checks numbers in the record number column) then it saves the database and without the newly added record... it looks very bad on me as a programmer everything else in the program is perfecto just this one step needs help...

    Help Girl...!!!!!!!!!

    :w00t: Jeff

  • If it's an identity, why are the users allowed to enter a number? With identities, SQL allocates the numbers, not the client app. Also, with an identity, if a row is deleted, that value will not appear in the table unless someone does a reseed or an identity insert (which is kinda against the point of an identity) and hence won't be there to cause a duplicate error

    Perhaps you can post the table's script and the proc that checks the numbers and inserts. It sounds like you're doing something strange.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply