Setting Primary key to zero

  • How do I set primary key to zero and add a new set of data to my table? Any suggestion will be appreciated.

  • Can you give more details about what you are trying to accomplish?

  • A primary key is the column(s) that uniquely identify each row. You don't set a PK to anything, you set the PK in each row to a unique value. That value is determined by the data, or it's a surrogate with something like NewID() or identity.

  • Are you talking about an identity column perhaps?

    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 have some data currently in my table and I want to flush them and add a new set of data. So I thought setting the Primary key to zero will help. Any other suggestions will be be appreciated:-)

  • DELETE FROM <tablename>

    or

    TRUNCATE <TableName>

    Both will remove all data from the table.

    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
  • If you have an identity column, DBCC CHECKIDENT will help you reseed the column. If you have other types of PKs, just add new data.

  • Thanks guys. It worked. Appreciate it

Viewing 8 posts - 1 through 8 (of 8 total)

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