Sql Delete触发多行

时间:2018-02-20 17:24:46

标签: mysql sql

我需要对几行进行触发,但我不知道我是怎么做到的,我已经尝试搜索但我只是设法找到那里的代码,我想知道是否有人可以帮助我。谢谢。

Create Trigger UXExcelFile_DELETE on UXExcelFile 
after delete
AS
Begin
Set nocount on 
Declare @TransDate date
Declare @TransTime Time(7)
Declare  @CardNo  varchar(255)
Declare @VoucherNo varchar(255)
Declare @Quantity varchar(150)
Declare @TransactionValue varchar(150)
Declare @Morada varchar(255)

select @TransDate =deleted.TransDate,@TransTime=deleted.TransTime,@CardNo = deleted.CardNo, @VoucherNo = deleted.VoucherNo, @Quantity = deleted.Quantity, @TransactionValue = deleted.TransactionValue, @Morada = deleted.Morada from deleted

Insert into UXExcelFileTrigger (TransDate,TransTime,CardNo,VoucherNo,Quantity,TransactionValue,Morada)values(@TransDate,@TransTime,@CardNo,@VoucherNo,@Quantity,@TransactionValue,@Morada)

END

1 个答案:

答案 0 :(得分:0)

我没有测试过代码,但我认为它会是这样的:

Create Trigger UXExcelFile_DELETE on UXExcelFile 
after delete
AS
Begin
Set nocount on 

Insert into UXExcelFileTrigger (TransDate,TransTime,CardNo,VoucherNo,Quantity,TransactionValue,Morada)
    SELECT TransDate, TransTime, CardNo, VoucherNo, Quantity, TransactionValue, Morada
    FROM deleted

END