在删除关联记录时,我的删除 Tsql 出现问题,有人可以帮我解决它吗
ALTER PROCEDURE [dbo].[Delete_Resource]
@ResID INT,
@UserID uniqueidentifier
AS
BEGIN
DELETE FROM [ideaPark_DB].[dbo].[Topics_Resources]
WHERE [ideaPark_DB].[dbo].[Topics_Resources].ResourceID = @ResID
DELETE FROM [ideaPark_DB].[dbo].[Likes]
WHERE [ideaPark_DB].[dbo].[Likes].resourceID = @ResID
declare @BookmarkID INT;
SET @BookmarkID = (SELECT [ideaPark_DB].[dbo].[Bookmarks].id FROM [ideaPark_DB].[dbo].[Bookmarks] WHERE [ideaPark_DB].[dbo].[Bookmarks].resourceID = @ResID and Bookmarks.userID = @UserID)
DELETE FROM [ideaPark_DB].[dbo].[Bookmarks]
WHERE [ideaPark_DB].[dbo].[Bookmarks].resourceID = @ResID
DELETE FROM [ideaPark_DB].[dbo].Bookmarks_Groups
WHERE Bookmarks_Groups.bookmarkID = @BookmarkID
delete FROM [ideaPark_DB].[dbo].[Resources_Relationship]
WHERE [ideaPark_DB].[dbo].[Resources_Relationship].fk_parent = @ResID
DELETE FROM [ideaPark_DB].[dbo].[Skills_Resources]
WHERE [ideaPark_DB].[dbo].[Skills_Resources].ResourceID = @ResID
DELETE FROM [ideaPark_DB].[dbo].[Resources]
WHERE [ideaPark_DB].[dbo].[Resources].Id = @ResID
END
错误
发生严重错误。DELETE 语句与 REFERENCE 约束“FK_Resources_Relationship_Resources1”冲突。冲突发生在数据库“ideaPark_DB”、表“dbo.Resources_Relationship”、列“fk_child”中。该语句已终止。-