Rebuild Primary Key(s) on a table/database

  • I copied a database and for some reason, they some primary keys were not reproduced. What is the best way to rebuild primary keys on a table or entire database?

  • You should take Database backup - Complete

    to resolve your problem.

  • How did you "copy" it?  Using DTS, database backup, detach/attach?

  • I detached the database created copied of the database files and them re-attached.

  • Hmm... Maybe better check your original db..? I can't see how any objects can disappear when doing a detach-attach. Make sure that the PKs you miss really is there in the original database.

    /Kenneth

  • I did check and verified that some of the primary keys were lost, or I think I had problems re-attaching at that time. So, to restore the original primary keys on a select group of tables, what would be the best approach?

  • I think you should recopy the database - if you have somhow mysteriously lost primary keys, you have probably lost other things as well and are lucky it is not marked as suspect in SQL.

Viewing 7 posts - 1 through 6 (of 6 total)

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