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)
 cascade update

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2010-11-01 : 12:33:46
Hi,

I have two table.
First table is column ID, FirstName
Second table is column ID, FirstName.

Data:
First table
ID, FirstName
1, FirstName
2,FirstName
3,FirstName
4,FirstName
5,FirstName

Second table
ID, FirstName
1, FirstName
2,FirstName
3,FirstName
4,FirstName
5,FirstName


Cascade delete functions.
If I delete the first table ID 2, is also deleted in another table.

But I have a problem with the update data.

in the first table I want in the data ID = 4 replace FirstName4

However, in another table, this information does not change.

In this case, the table should look like:
Data:
First table
ID FirstName
1, FirstName
2, FirstName
3, FirstName
4, FirstName4 - switch
5, FirstName

Second table
ID FirstName
1, FirstName
2, FirstName
3, FirstName
4, FirstName4 automatically be replaced.
5, FirstName

Please help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-01 : 12:40:45
you need to write a trigger on your table 1 for doing this operations on table 2 automatically

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-11-01 : 12:59:20
As far as I know cascading referential integrity considers the keys and not some "other" columns.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-11-01 : 13:42:27
If you can you should fix up your schema before things get worse.

http://en.wikipedia.org/wiki/Database_normalization
Go to Top of Page
   

- Advertisement -