Query für Rekursives löschen

image_pdfimage_print

DECLARE @ObjectID UNIQUEIDENTIFIER = '18AAF1E3-FBFC-4BB1-957A-60AD7EFC0276' 
 WITH RowsToDelete AS (
     SELECT [ID]
     FROM [Security].[PermissionLevel]
     WHERE [ID] = @ObjectID

UNION ALL

SELECT [Child].[ID]
FROM [Security].[PermissionLevel] Child 
INNER JOIN RowsToDelete Parent ON Parent.[ID] = [Child].[ParentID]
)
 DELETE FROM [Security].[PermissionLevel]
 FROM [Security].[PermissionLevel] h 
 INNER JOIN RowsToDelete d on h.ID = d.ID
 go

leave your comment

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.