有人可以解释为什么会这样 -
CREATE TRIGGER [dbo].[T_tskmst_D]
ON [dbo].[tskmst]
FOR DELETE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for trigger here
insert into [database].[dbo].[tskmst] (
tskmst_revtm, tskmst_revtype, tskmst_id, tskmst_name, tskmst_desc,
tskmst_type, owner_id, tskmst_public, tskmst_lstchgtm,
nodmst_id, servicemst_id)
select GETDATE(), 'D', d.tskmst_id, d.tskmst_name, d.tskmst_desc,
d.tskmst_type, d.owner_id, d.tskmst_public, d.tskmst_lstchgtm,
d.nodmst_id, d.servicemst_id
from deleted d
END
但这不是 -
CREATE TRIGGER [dbo].[T_tskmst_D]
ON [dbo].[tskmst]
FOR DELETE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for trigger here
insert into [database].[dbo].[tskmst] (
tskmst_revtm, tskmst_revtype, tskmst_id, tskmst_name, tskmst_desc,
tskmst_type, owner_id, tskmst_public, tskmst_lstchgtm,
nodmst_id, servicemst_id)
select GETDATE(), 'D', d.tskmst_id, d.tskmst_name, d.tskmst_desc,
d.tskmst_type, d.owner_id, d.tskmst_public, d.tskmst_lstchgtm,
d.nodmst_id, d.servicemst_id
from deleted d
inner join tskmst tm on tm.tskmst_id = d.tskmst_id
END
我很困惑为什么删除内部联接会阻止查询能够复制信息?是因为在内部联接发生之前删除了数据吗?是否可以在删除之前复制数据?
我可以从删除但是问题是某些表包含文本列(不要问)所以我无法从删除的其他地方插入我缺少某些列。
答案 0 :(得分:1)
它不起作用,因为它是FOR删除触发器。 这意味着表中不存在已删除的行。
当你加入任何东西时,你什么也得不到。