我想弄清楚一种方法来创建一个循环,将从不同的表的列中获取一个id并使用该id来执行删除操作。创建循环使用来自另一个表中的值来执行删除
@ID
表示与另一个表的不同ID。我如何创建一个循环来读取每个ID并删除基于该ID的其他表中的行?
Declare @ID int
Set @ID = dbo.control.id
Delete from dbo.search where [email protected]
Delete from dbo.searchfolder where [email protected]
Delete from dbo.application where id [email protected]
除非循环中有其他逻辑,否则不需要其他逻辑。只需在你的'delete'语句中使用'join'。 – sgeddes
id会有所不同。 – Jeff