Search code examples
sqlsql-server-2008primary-keyrelational-databaseidentity-column

Is there a smart way to append a number to an PK identity column in a Relational database w/o total catastrophe?


It's far from the ideal situation, but I need to fix a database by appending the number "1" to the PK Identiy column which has FK relations to four other tables. I'm basically making a four digit number a five digit number. I need to maintain the relations. I could store the number in a var, do a Set query and append the 1, and do that for each table...

Is there a better way of doing this?


Solution

  • Consider adding another field to the PK instead of extending the length of the PK field. Your new field will have to cascade to the related tables, like a field length increase would, but you get to retain your original PK values.