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
 Transact-SQL (2000)
 update parent key in referential integrity

Author  Topic 

raviravi
Starting Member

8 Posts

Posted - 2006-12-21 : 02:11:30
Dear all,
I have a parent table which has many dependent tables.
Now I want to update parent key and want this should be reflected in the all child table.
I want to update all these children table without disabling foreign key constraint.
I have tried an update trigger but all efforts are in vain.
Please help me ASAP.
Your support will be highly appreciated.
Regards.

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-12-21 : 02:14:34
How about creating new parents with their children records and then deleting the ones that you wanted to change and all of their children?


Duane.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-21 : 02:47:24
Or, you can enable CASCADE UPDATE...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

raviravi
Starting Member

8 Posts

Posted - 2006-12-21 : 03:08:40
Dear Peter,
thanks for your reply
Thats true sql server perform this thing internally is it not possible for us to do manually?
cant we write after update trigger for master table where we can cascade
the change by some sql statements.
Thanks.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-21 : 03:16:31
If CASCADING UPATE is enabled, all foreign keys are updates by the SQL Server whenever the PK is updated.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -