onebite2
asked on
Update Reference/Foreign tables
Database: SQL Server2005.
I have Glossary table with bunch of Foreign Key relationship tables. Glossary table has some invalid data and same exists on the other relation tables.. Now in order to delete those invalid values out of Glossary i need remove them various other tables... so i wrote a update statement for each foreign key table(reference table) but that tidous process.. is there any way i can do this.. other than updating every single foreign key table..
For instance: TableA has foreign key relations with TableB,TableC, TableD..
Fields on TableA: UniqueID,Category,Descript ion (UniqueID is a Primary Key on Table A and Foreign key table on TableB and also Foreign key table on TableC..) So i can't delete a UniqueID on TableA since the value exists on TableB, TableC.. So i want TableB & TableC to update with correct values and delete the invalid value from TableA but i dont want to write too many update queries..
Hope my question is clear! Let me know if you have any questions.
Need to know what's the best way to deal with this issue.
Thanks,
Cindy
I have Glossary table with bunch of Foreign Key relationship tables. Glossary table has some invalid data and same exists on the other relation tables.. Now in order to delete those invalid values out of Glossary i need remove them various other tables... so i wrote a update statement for each foreign key table(reference table) but that tidous process.. is there any way i can do this.. other than updating every single foreign key table..
For instance: TableA has foreign key relations with TableB,TableC, TableD..
Fields on TableA: UniqueID,Category,Descript
Hope my question is clear! Let me know if you have any questions.
Need to know what's the best way to deal with this issue.
Thanks,
Cindy
ASKER
Is there any to get foreign key tables and the fields using sql statement, Let me know
ASKER
I had to spend more time on this but I wrote the sql.. I think its worth spending time on the sql instead of manually writing update statement. I get to know lots of new things.. informative.. but thanks for the help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Force accepted.
Vee_Mod
Community Support Moderator
Vee_Mod
Community Support Moderator
With a select starting from sysforeignkeys you can speed up your typing.