Para borrar una orden de pago utilizar este script. Modificando el valor de Ordendepagoid
DECLARE @ordenPagoID INT
SET @ordenPagoID =1096
DECLARE @fecha DATE
SET @fecha = (select fecha from Gestion.OrdenPago where OrdenPagoID=@ordenPagoID)
DECLARE @importe MONEY
SET @importe = (select OrdenPago.ImEfectivo+OrdenPago.ImDepositosEfectivo+OrdenPago.ImCheques from Gestion.OrdenPago where OrdenPagoID=@ordenPagoID)
update
Gestion.ProveedorDocumento
set
ImCancelado=0
where
ProveedorDocumentoID in (
select ProveedorDocumentoID from Gestion.OrdenPagoDocumento where OrdenPagoID=@ordenPagoID)
delete from Gestion.PRCuentaCorrienteMov where OrdenPagoID=@ordenPagoID
delete from Gestion.OrdenPagoDocumento where OrdenPagoID=@ordenPagoID
delete from Gestion.PaseOrdenPago where OrdenPagoID=@ordenPagoID
delete from CtaBancariaMov where Fecha = @fecha and CtaBancariaTrxId=2200 and ImporteMonex=@importe
delete from Gestion.OrdenPago where OrdenPagoID=@ordenPagoID