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 2000 Forums
 SQL Server Administration (2000)
 changing primary key column values

Author  Topic 

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2006-03-21 : 18:41:28
Hi All,

We have 2 databases on 2 different sites. Now we decided to merge these 2 databases.

Problem: both site got same job numbers.
Solution:- Change job number for 1 site before merging.

Here is db structure

table: job
jobnumber (PK)

table :ref1
jobnumber (FK to job.jobnumber)

table :ref2
jobnumber (FK to jobnumber)

table : a
jobnumber (data from job.jobnumber not linked by FK)

table : b
jobnumber (data from job.jobnumber not linked by FK)

I have around 50 tables.
Now i need to change jobnumbers in all table.


What will be best technique to do it?






mk_garg

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-03-22 : 06:08:47
Copy the data into a staging table, drop the original data, re-seed the jobnumber (i'm guessing it's an identity as you haven't said any different), then reinsert the data..
Go to Top of Page

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2006-03-22 : 18:39:56
Thanks

mk_garg
Go to Top of Page
   

- Advertisement -