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.
| Author |
Topic |
|
osirisa
Constraint Violating Yak Guru
289 Posts |
Posted - 2009-11-08 : 19:17:08
|
| Hi Group:How can I delete a Record that is part of a Main Table and then also delete any other record associate with that record in other tables. I will give you an example.------------------------------ DELETE FROM dbo.Project WHERE Project_Id = @ProjId----------------------------I want to Delete all Taks related to this project that can be around 5-10 different Task. So first I select all the Taks relate to the Specific Project --- So this is the Statement that I created but as you can see, it is not working. ---------------------------Delete SELECT a.[ID], a.[Title], a.[Priority], a.[Status],b.[Last Name]+ ' '+ [First Name] As Full_Name, a.[Description],convert(char(10), a.[Start Date], 101) as [Start Date], convert(char(10), a.[Due Date], 101) as [Due Date] FROM dbo.Tasks a inner join Employees b on a.[Assigned To] = b.[id]inner join Projects c on a.[Project]= c.[id]Where [Project Number] = @ProjId ------------------------------Thank you for your help......I appreciate it. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-11-09 : 10:55:14
|
| or you need to specify ON DELETE CASCADE options when you define foreign key constraints on the child tables |
 |
|
|
|
|
|
|
|