0
我有這個觸發我做觸發不插入正確的行
alter trigger fuzzylogic on oehdrhst_sql
for insert
as
begin
declare @ordno char(8)
declare @rownum int
declare @id int
select @ordno = ord_no from inserted
select @rownum = a.id from banktransactions a where convert(char(8),a.OwnReference) = (select ord_no from inserted)
select @id = a.id from banktransactions a join inserted i on i.ord_no = a.invoicenumber
where a.invoicenumber = @ordno
begin
insert into triggertest values(@ordno,@rownum,@id)
update banktransactions set matchid = @rownum,SupplierInvoiceNumber = @ordno where id = @id
end
end
當我看到裏面triggertest之後我插入一行我看ordno和ROWNUM,但我不斷收到空上的ID
我跑這個sql語句來測試,看看查詢是否不會返回任何東西,但它確實。
select a.id from banktransactions a join oehdrhst_sql b on a.invoicenumber = b.ord_no
爲什麼變量不打印?
你會分享如何做到這一點? – user867621