Ask the Expert

Updating existing records with new primary key

I have a SQL Server 2000 database with several tables that use a social security number as a primary key. I am working to update this system to no longer use social security numbers as a key, but to instead use another assigned number. What would be the best way to update the existing records in the database with the new key?

    Requires Free Membership to View

Create a mapping table that maps the old ID to the new ID, generate a new ID for each one, and then use that to populate your new column to ensure all of the relationships come across intact.

 

For More Information

This was first published in April 2003

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.