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 |
|
chakri002
Starting Member
1 Post |
Posted - 2008-05-08 : 18:15:18
|
| I have 4 colums in a tableProject, Sections,Tasks,SubtasksEach subtask will haven a row.I need to write a trigger when I delete a task it needs to delete all the subtasks relating to it. When I delete a section it needs to delete all the tasks and subasks relating to it. similarly for project.This trigger for task-subtask works.CREATE TRIGGER "[Deletetasktrigger]" ON [Tbl] FOR DELETE ASSET NOCOUNT ON/* * CASCADE DELETES TO '[Tbl B]' */DELETE [tbl] FROM deleted, [Tbl] WHERE deleted.[task] = [Tbl].[task]THis works fine. But when I do it for sections I get this error."Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)" ..Help Please!!!!!! |
|
|
sanoj_av
Posting Yak Master
118 Posts |
Posted - 2008-05-09 : 05:55:13
|
The Probable reason is that you might be using Delete Triger in two or more tbles that try to delete the rows of each other which produce a circular non-ending loop.quote: Originally posted by chakri002 I have 4 colums in a tableProject, Sections,Tasks,SubtasksEach subtask will haven a row.I need to write a trigger when I delete a task it needs to delete all the subtasks relating to it. When I delete a section it needs to delete all the tasks and subasks relating to it. similarly for project.This trigger for task-subtask works.CREATE TRIGGER "[Deletetasktrigger]" ON [Tbl] FOR DELETE ASSET NOCOUNT ON/* * CASCADE DELETES TO '[Tbl B]' */DELETE [tbl] FROM deleted, [Tbl] WHERE deleted.[task] = [Tbl].[task]THis works fine. But when I do it for sections I get this error."Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)" ..Help Please!!!!!!
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-09 : 06:27:21
|
You can also use a simple CTE to make a "recursive" delete.Examples are in Books Online. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|