IF (EXISTS (select proc_name from sysprocedure where LCase(proc_name)=LCase('DeleteAllChildren'))) THEN Drop procedure DeleteAllChildren END IF GO create procedure DeleteAllChildren(in ContractN integer) Begin Update Contracts set Active=0 where ContractNo=ContractN; for f as curr scroll cursor for select ContractNo as @ContractNo from Contracts where Active=1 and ContractNode=ContractN and ContractNo<>ContractNode do call DeleteAllChildren(@ContractNo); end for; end