C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Delete Parent & Child Relationship


Posted Date: 10 Jan 2009      Posted By: Gaurav Agrawal      Member Level: Diamond     Points: 1   Responses: 2



Hi this is my table format
----------------------------------------
id name pid
-------------------
1 a 0
2 b 1
3 c 1
4 d 2
5 e 0
----------------------------------------

in this when i delete id=1 that time delete all records which has parent i.e pid=1 here 1 is the grant parent of most of the records
and after the deletion only id=5 row has been saved in the table

can anyone give me the procedure that how i can do this????

Thanks
GA

Thanks & Regards,

Gaurav Agrawal
Sr.Software Engineer
gaur1982@yahoo.com
09829373514





Responses

Author: Pascal    10 Jan 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 3

Requirement is not clear.. Usually when the parent is deleted, child should be deleted. Something like we have a parentTable and a childTable. ParentTable primary key is the foreign key in the childTable. So if we delete a record in the ParentTable then all its related records in the childTable should be deleted. To do so we use "Delete on cascade" option.

If i am wrong can you explain your requirement in detail?



Author: karthick    10 Jan 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 1

your information is not understandable, give a proper info i ill help you out with this


Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Conversion problem
Previous : About database
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use