SELECT IIF(not table='CUSTPAYMENT',999999999999,newid('CUSTPAYMENT')) as nextid ; > FROM ids WHERE table='CUSTPAYMENT' INTO CURSOR tNextIdI don't know why the SP gets executed twice.
SELECT (fieldlist) from ids where WHERE table='CUSTPAYMENT'; INTO CURSOR tNextId nofilter select *, IIF(not table='CUSTPAYMENT',999999999999,newid('CUSTPAYMENT')) as nextid; from tNextId into cursor tNextId