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 Development (2000)
 Cascading updates in MS SQL Server 7.0

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-30 : 07:59:40
Aaron writes "I am trying to find the best way to achieve cascading updates in MS SQL Server 7.0. Right now I have foreign key relationships between several tables to enforce data integrity, however there are times when I want to change the primary key and cascade that new key down through the other tables. I've thought about using a trigger to detect the primary key change, then update the other tables. However, to do this, I would have to temporarily disable all the foreign keys, then update all the tables, then re-enable the foreign keys. I also can't change the primary key to null first, then change to the new value. Given the number of tables that will be cascaded to (around 10) creating a new record first in each of the tables then deleting the old records seems like it would take too much time. Any other ideas? Thanks."

chadmat
The Chadinator

1974 Posts

Posted - 2003-07-30 : 20:02:04
The only way to really do it in 7.0 is to disable your FK constraints, and manage it all with triggers. You could upgrade to 2000, and then it is a very simple addition of the CASCADE directive.

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page
   

- Advertisement -