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 2008 Forums
 Transact-SQL (2008)
 Deleating references from multiple tables

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2014-11-05 : 10:23:09
I have 4 tables"

team
ID
NAME

TeamProperties
ID
TEAMID
NAME

teamRole
ID
TEAMID
TEAMROLEID


roleCandidate
ID
ROLEID

Team is the main table
TeamProperties joins to the Team table by ID-TEAMID
roleCandidate joins to the teamRole table by TEAMROLEID-ID
teamRole joins to the team table by TEAMID-ID

I need to delete all reference in the TeamProperties, teamRole, roleCandidate and to these table that belong to a certain team. All I have is the ID for the Team table. Can't get my head wrapped around it

Dave
Helixpoint Web Development
http://www.helixpoint.com

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-11-05 : 16:58:10
Short answer: Delete from each table where TEAMID = YourValue
Longer answer: Create foreign keys on each child table to the Team table that have a cascading delete defined. Delete from Team where TEAMID = YourValue.



No amount of belief makes something a fact. -James Randi
Go to Top of Page
   

- Advertisement -