CREATE TABLE tm_BalPspto ( 
tmEst CHAR(2) NOT NULL,
IdCuenta VARCHAR(16) NOT NULL,
IdCCosto VARCHAR(16) NOT NULL,
IdSubCos VARCHAR(16) NOT NULL,
IdCia CHAR(2) DEFAULT ('00') NOT NULL,
VrPstoEne MONEY DEFAULT (0) NOT NULL,
VrSanEne MONEY DEFAULT (0) NOT NULL,
VrDebEne MONEY DEFAULT (0) NOT NULL,
VrCreEne MONEY DEFAULT (0) NOT NULL,
VrPstoFeb MONEY DEFAULT (0) NOT NULL,
VrSanFeb MONEY DEFAULT (0) NOT NULL,
VrDebFeb MONEY DEFAULT (0) NOT NULL,
VrCreFeb MONEY DEFAULT (0) NOT NULL,
VrPstoMar MONEY DEFAULT (0) NOT NULL,
VrSanMar MONEY DEFAULT (0) NOT NULL,
VrDebMar MONEY DEFAULT (0) NOT NULL,
VrCreMar MONEY DEFAULT (0) NOT NULL,
VrPstoAbr MONEY DEFAULT (0) NOT NULL,
VrSanAbr MONEY DEFAULT (0) NOT NULL,
VrDebAbr MONEY DEFAULT (0) NOT NULL,
VrCreAbr MONEY DEFAULT (0) NOT NULL,
VrPstoMay MONEY DEFAULT (0) NOT NULL,
VrSanMay MONEY DEFAULT (0) NOT NULL,
VrDebMay MONEY DEFAULT (0) NOT NULL,
VrCreMay MONEY DEFAULT (0) NOT NULL,
VrPstoJun MONEY DEFAULT (0) NOT NULL,
VrSanJun MONEY DEFAULT (0) NOT NULL,
VrDebJun MONEY DEFAULT (0) NOT NULL,
VrCreJun MONEY DEFAULT (0) NOT NULL,
VrPstoJul MONEY DEFAULT (0) NOT NULL,
VrSanJul MONEY DEFAULT (0) NOT NULL,
VrDebJul MONEY DEFAULT (0) NOT NULL,
VrCreJul MONEY DEFAULT (0) NOT NULL,
VrPstoAgo MONEY DEFAULT (0) NOT NULL,
VrSanAgo MONEY DEFAULT (0) NOT NULL,
VrDebAgo MONEY DEFAULT (0) NOT NULL,
VrCreAgo MONEY DEFAULT (0) NOT NULL,
VrPstoSep MONEY DEFAULT (0) NOT NULL,
VrSanSep MONEY DEFAULT (0) NOT NULL,
VrDebSep MONEY DEFAULT (0) NOT NULL,
VrCreSep MONEY DEFAULT (0) NOT NULL,
VrPstoOct MONEY DEFAULT (0) NOT NULL,
VrSanOct MONEY DEFAULT (0) NOT NULL,
VrDebOct MONEY DEFAULT (0) NOT NULL,
VrCreOct MONEY DEFAULT (0) NOT NULL,
VrPstoNov MONEY DEFAULT (0) NOT NULL,
VrSanNov MONEY DEFAULT (0) NOT NULL,
VrDebNov MONEY DEFAULT (0) NOT NULL,
VrCreNov MONEY DEFAULT (0) NOT NULL,
VrPstoDic MONEY DEFAULT (0) NOT NULL,
VrSanDic MONEY DEFAULT (0) NOT NULL,
VrDebDic MONEY DEFAULT (0) NOT NULL,
VrCreDic MONEY DEFAULT (0) NOT NULL
 CONSTRAINT PK_tm_BalPspto PRIMARY KEY CLUSTERED (tmEst,IdCuenta,IdCCosto,IdSubCos,IdCia),
 CONSTRAINT CK_tm_BalPsptoIdCCosto CHECK ((len([IdCCosto]) > 0)),
 CONSTRAINT CK_tm_BalPsptoIdCia CHECK ((len([IdCia]) > 0)),
 CONSTRAINT CK_tm_BalPsptoIdCuenta CHECK ((len([IdCuenta]) > 0)),
 CONSTRAINT CK_tm_BalPsptoIdSubCos CHECK ((len([IdSubCos]) > 0)),
 CONSTRAINT CK_tm_BalPsptotmEst CHECK ((len([tmEst]) > 0)))
GO
 CREATE NONCLUSTERED INDEX IX_tm_BalPsptoIdCuenta ON tm_BalPspto(IdCuenta)
 CREATE NONCLUSTERED INDEX IX_tm_BalPsptoIdCCosto ON tm_BalPspto(IdCuenta,IdCCosto)
ALTER TABLE Sys_TiposDoc ADD IntegraCias BIT DEFAULT(0) NOT NULL
GO
CREATE TABLE TanqAforoFrac ( 
IdTanque VARCHAR(4) NOT NULL,
UndAforo DECIMAL(14,4) DEFAULT (0) NOT NULL,
Fraccion DECIMAL(14,4) DEFAULT (0) NOT NULL,
Milimetros DECIMAL(14,4) DEFAULT (0) NOT NULL
 CONSTRAINT PK_TanqAforoFrac PRIMARY KEY CLUSTERED (IdTanque,UndAforo),
 CONSTRAINT CK_TanqAforoFracIdTanque CHECK ((len([IdTanque]) > 0)))
GO
ALTER TABLE TanqAforoFrac ADD 
 CONSTRAINT FK_TanqAforoFrac_Tanques FOREIGN KEY (IdTanque) REFERENCES [dbo].[Tanques] (IdTanque)
