我希望刪除結果select語句返回,原因我這樣做是因爲我有表之間的關係,如果我從最頂級的表中刪除其子表中的子行也被刪除。SQL Server存儲過程刪除語句
任何人都可以爲我糾正這個存儲過程嗎?
ALTER proc [dbo].[storedprocname]
(@Parameter uniqueidentifier = '00000000-0000-0000-0000-000000000000')
AS BEGIN
DELETE FROM TableOne
WHERE IDOne IN
(SELECT
IDOne,
DescOne, IndexOne,
IDTwo,
QuestionTwo, ControlTypeTwo, IndexTwo,
IDThree,
DescThree, IndexThree,
QuestionFour,
OptionFour
FROM
TableOne
INNER JOIN
TableTwo ON TableTwo.CatID = TableOne.IDOne
INNER JOIN
TableThree ON TableThree.Question = TableTwo.IDTwo
LEFT OUTER JOIN
TableFour ON TableFour.Question = TableThree.IDThree
WHERE
TableOne.IDOne = @Parameter)
END