我有一个正在制作的数据库,并且已被引入进行更改。一切顺利,除了我无法执行DELETE。我知道这是因为加入和错误的引用。诚信等但我无法真正改变这一点。 下面的select语句没有问题,并在gridview中显示:
SELECT
[Stock Inventory].MaterialNumber,
[Stock Inventory].[Optimum Stock] AS Optimum_Stock,
customerservice.Part,
customerservice.SamplesRequired,
customerservice.Frequency,
customerservice.Country
FROM
[Stock Inventory]
INNER JOIN customerservice
ON [Stock Inventory].MaterialNumber = customerservice.Part
我希望使用属于生成表的一部分的删除链接 如果我没有提供足够的信息,请告诉我
答案 0 :(得分:0)
由于您提到需要从两个表中删除,您可以执行以下操作:
begin transaction
declare @deleted table (MaterialNumber int) --whatever data type you need
DELETE s
output deleted.MaterialNumber into @deleted
from [Stock Inventory] as s
INNER JOIN customerservice as c
ON s.MaterialNumber = c.Part
DELETE c
from customerservice as c
join @deleted d
on d.MaterialNumber = c.Part
commit transaction