ALTER TABLE Trn_FinCausacion ADD TotalOtros MONEY DEFAULT(0) NOT NULL
GO
CREATE TABLE Trn_FinCausaRec ( 
TipoProc VARCHAR(3) DEFAULT ('CAU') NOT NULL,
NumProc INT DEFAULT (0) NOT NULL,
IdCia CHAR(2) DEFAULT ('01') NOT NULL,
Item INT DEFAULT (0) NOT NULL,
TipRec VARCHAR(3) DEFAULT ('RC2') NOT NULL,
Recibo INT DEFAULT (0) NOT NULL,
IdCiaRec CHAR(2) DEFAULT ('01') NOT NULL,
VrCapital MONEY DEFAULT (0) NOT NULL,
TipPrest VARCHAR(3) DEFAULT ('PR1') NOT NULL,
NumPrest INT DEFAULT (0) NOT NULL,
IdCiaPrest CHAR(2) DEFAULT ('01') NOT NULL,
ItemPrest INT DEFAULT (1) NOT NULL,
NCuota INT DEFAULT (0) NOT NULL
 CONSTRAINT PK_Trn_FinCausaRec PRIMARY KEY CLUSTERED (TipoProc,NumProc,IdCia,Item),
 CONSTRAINT CK_Trn_FinCausaRecIdCia CHECK ((len([IdCia]) > 0)),
 CONSTRAINT CK_Trn_FinCausaRecIdCiaPrest CHECK ((len([IdCiaPrest]) > 0)),
 CONSTRAINT CK_Trn_FinCausaRecIdCiaRec CHECK ((len([IdCiaRec]) > 0)),
 CONSTRAINT CK_Trn_FinCausaRecTipoProc CHECK ((len([TipoProc]) > 0)),
 CONSTRAINT CK_Trn_FinCausaRecTipPrest CHECK ((len([TipPrest]) > 0)),
 CONSTRAINT CK_Trn_FinCausaRecTipRec CHECK ((len([TipRec]) > 0)))
CREATE TABLE Trn_FinPrestSeguro ( 
TipDoc VARCHAR(3) DEFAULT ('PR1') NOT NULL,
IdPrestamo INT DEFAULT (0) NOT NULL,
IdCia CHAR(2) DEFAULT ('01') NOT NULL,
Item INT DEFAULT (0) NOT NULL,
TarifSeguro MONEY DEFAULT (0) NOT NULL
 CONSTRAINT PK_Trn_FinPrestSeguro PRIMARY KEY CLUSTERED (TipDoc,IdPrestamo,IdCia,Item),
 CONSTRAINT CK_Trn_FinPrestSeguroIdCia CHECK ((len([IdCia]) > 0)),
 CONSTRAINT CK_Trn_FinPrestSeguroTipDoc CHECK ((len([TipDoc]) > 0)))
GO
ALTER TABLE Trn_FinPrestSeguro ADD 
 CONSTRAINT FK_Trn_FinPrestSeguro_Trn_FinPrestamo FOREIGN KEY (TipDoc,IdPrestamo,IdCia) REFERENCES [dbo].[Trn_FinPrestamo] (TipDoc,IdPrestamo,IdCia)
