When i use this code it inserts row
create trigger [dbo].[InsertInvPayment] on dbo.LG_001_01_PAYTRANS
after update
as
begin
SET NOCOUNT ON;
declare @InvLogicalRef int;
declare @InvNumber varchar(50);
select @InvLogicalRef = inserted.FICHEREF from inserted
select @InvNumber = dbo.LG_001_01_INVOICE.DOCODE from dbo.LG_001_01_INVOICE where dbo.LG_001_01_INVOICE.LOGICALREF = @InvLogicalRef
insert into dbo.CRMINVPAYMENT(INVNUMBER) values('Hello')
end
if i change it like this
create trigger [dbo].[InsertInvPayment] on dbo.LG_001_01_PAYTRANS
after update
as
begin
SET NOCOUNT ON;
declare @InvLogicalRef int;
declare @InvNumber varchar(50);
select @InvLogicalRef = inserted.FICHEREF from inserted
select @InvNumber = dbo.LG_001_01_INVOICE.DOCODE from dbo.LG_001_01_INVOICE where dbo.LG_001_01_INVOICE.LOGICALREF = @InvLogicalRef
insert into dbo.CRMINVPAYMENT(INVNUMBER) values(@InvNumber)
end
it doesn't work. i couldn't find a mistake in the second
insertedmay contain 0, 1 or many rows.