declare @acmastid varchar(40) DECLARE h1 CURSOR FOR SELECT acmastid from depositviewall where type =3 OPEN h1 FETCH NEXT FROM h1 INTO @acmastid WHILE @@FETCH_STATUS = 0 BEGIN delete from acmast where acmastid = @acmastid delete from acOp where acmastid = @acmastid delete from acmastK where acmastid = @acmastid delete from acExtra where acmastid = @acmastid delete from acMem where acmastid = @acmastid delete from pledgeSalary where acmastid = @acmastid delete from acNote where acmastid = @acmastid delete from nominee where acmastid = @acmastid delete from logmast where facttableid = @acmastid delete from logdet where facttableid = @acmastid delete from deposit where acmastid = @acmastid delete from intTran where acmastid = @acmastid delete from dpIntShdl where acmastid = @acmastid delete from acIntDet where acmastid = @acmastid delete from dpRnwAc where acmastid = @acmastid FETCH NEXT FROM h1 INTO @acmastid END DEALLOCATE H1