используйте это:
insert into PaymentMemo (fld1,fld2,fld3)
SELECT CASE WHEN @AmountPaid > InvAmount then valu1 WHEN @AmountPaid = InvAmount then valu4 end,
CASE WHEN @AmountPaid > InvAmount then valu2 WHEN @AmountPaid = InvAmount then valu5 end,
CASE WHEN @AmountPaid > InvAmount then valu3 WHEN @AmountPaid = InvAmount then valu6 end,
from Invoice where InvNo = @InvNo
Или используйте динамическое выражение, например:
declare @InsertStmnt nvarchar(max)
SELECT @InsertStmnt= CASE
SELECT CASE WHEN @AmountPaid > (SELECT InvAmount from Invoice where InvNo = @InvNo) THEN
'INSERT INTO PaymentMemo (fld1,fld2,fld3) values(valu1,valu2,valu3)'
WHEN @AmountPaid = (SELECT InvAmount from Invoice where InvNo = @InvNo) THEN
'INSERT INTO PaymentMemo (fld1,fld2,fld3) values(valu4,valu5,valu6)'
END
exec (@InsertStmnt)
Вы можете передать valu1,valu2,valu3
или valu4,valu5,valu6
динамически