1

I have a table set up to hold folders. Each folder has an ID, a ParentID and a couple other columns.

  ID | ParentID | Name
   1    Null      Base Folder
   2    1         Folder 1
   3    2         Folder 2

   etc

I'm working on a delete function but I'm running into issues getting everything nested inside a folder. Things can be nested ad infinitum.

So if I run my query on Base Folder I'd want to delete Base Folder, Folder 1, and Folder 2

Any ideas on how to go about doing this?

4

1 回答 1

0

Take a look at ON DELETE CASCADE :

http://msdn.microsoft.com/en-us/library/ms186973%28v=sql.105%29.aspx

Just make sure you read this carefully and are sure this is the behavior you want.

于 2012-06-14T16:06:32.337 回答