Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to repopulate Primary and Foreign Key?

Author  Topic 

SCHEMA
Posting Yak Master

192 Posts

Posted - 2010-07-24 : 20:27:10

Someone has manually entered Primary Key Column of some tables like :
C1D13F0F-3E04-4C43-9180-447C90DC4A90
C1D13F0F-3E04-4C43-9180-447C90DC4A91
C1D13F0F-3E05-4C43-9180-447C90DC4A90

and also in the same way, associated Foreign Key from other tables which is related to this table.

I want to completely Regenerate and Repopulate Primary Key with NEWID() and associate to the other Tables.
How to do??

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-07-25 : 03:53:36
How many records are there in the table and how many tables are related to the primary table.


Assuming that On Update cascade is not specified while creting table, what you can do is recreate the foreign key specifying on Update Cascade statement.

If possible use NewSequentialID() instead of NewID().

There are other approach too.
Go to Top of Page
   

- Advertisement -