ALTER TABLE PLATRANS ADD PLA_NCM INT DEFAULT(0),PLA_CCM CHAR(2)
GO
CREATE TABLE CUMPLIDOS ( 
CUM_TIP VARCHAR(3) NOT NULL,
CUM_NUM INT DEFAULT ((0)) NOT NULL,
CUM_CIA CHAR(2) DEFAULT ('01') NOT NULL,
CUM_FEC SMALLDATETIME NOT NULL,
CUM_TDC VARCHAR(3) DEFAULT ('PLT') NOT NULL,
CUM_NDC INT DEFAULT ((0)) NOT NULL,
CUM_CDC CHAR(2) NOT NULL,
CUM_RUT VARCHAR(3),
CUM_ORI VARCHAR(8),
CUM_DES VARCHAR(8),
CUM_NIT VARCHAR(11) NOT NULL,
CUM_VEH VARCHAR(10) NOT NULL,
CUM_CDT VARCHAR(11),
CUM_CON VARCHAR(3),
CUM_LPG VARCHAR(8),
CUM_DPG INT DEFAULT ((0)) NOT NULL,
CUM_FPG SMALLDATETIME,
CUM_POG DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
CUM_PES DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
CUM_VAL MONEY DEFAULT ((0)) NOT NULL,
CUM_COS MONEY DEFAULT ((0)) NOT NULL,
CUM_NET MONEY DEFAULT ((0)) NOT NULL,
CUM_VHC MONEY DEFAULT ((0)),
CUM_VHD MONEY DEFAULT ((0)),
CUM_VAD MONEY DEFAULT ((0)),
CUM_MVL VARCHAR(3),
CUM_VDC MONEY DEFAULT ((0)),
CUM_MVD VARCHAR(3),
CUM_FED SMALLDATETIME,
CUM_MTA VARCHAR(5),
CUM_OAC VARCHAR(250)
 CONSTRAINT PK_CUMPLIDOS PRIMARY KEY CLUSTERED (CUM_TIP,CUM_NUM,CUM_CIA),
 CONSTRAINT CK_CUMPLIDOSCUM_CDC CHECK ((len([CUM_CDC])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_CIA CHECK ((len([CUM_CIA])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_NIT CHECK ((len([CUM_NIT])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_TDC CHECK ((len([CUM_TDC])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_TIP CHECK ((len([CUM_TIP])>(0))),
 CONSTRAINT CK_CUMPLIDOSCUM_VEH CHECK ((len([CUM_VEH])>(0))))
GO
CREATE TABLE DETCUM ( 
DET_TIP VARCHAR(3) NOT NULL,
DET_NUM INT DEFAULT ((0)) NOT NULL,
DET_CIA CHAR(2) DEFAULT ('01') NOT NULL,
DET_ITM INT DEFAULT ((0)) NOT NULL,
DET_TDC VARCHAR(3) NOT NULL,
DET_NDC INT DEFAULT ((0)) NOT NULL,
DET_CDC CHAR(2) NOT NULL,
DET_IDC INT DEFAULT ((0)) NOT NULL,
DET_FDC SMALLDATETIME NOT NULL,
DET_PES DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DET_KGO DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DET_VAL MONEY DEFAULT ((0)) NOT NULL,
DET_COS MONEY DEFAULT ((0)) NOT NULL,
DET_NET MONEY DEFAULT ((0)) NOT NULL,
DET_ORI VARCHAR(8),
DET_CDE VARCHAR(8),
DET_UNI VARCHAR(3),
DET_NOV VARCHAR(3),
DET_RF1 VARCHAR(250),
DET_RF2 VARCHAR(250),
DET_RF3 VARCHAR(250),
DET_KRM DECIMAL(14,4) DEFAULT ((0)) NOT NULL,
DET_VRM MONEY DEFAULT ((0)) NOT NULL,
DET_CRM MONEY DEFAULT ((0)) NOT NULL,
DET_NRM MONEY DEFAULT ((0)) NOT NULL,
DET_COD VARCHAR(13),
DET_DES VARCHAR(250),
DET_CAN VARCHAR(10),
DET_CC VARCHAR(3),
DET_CLI VARCHAR(11),
DET_AGE VARCHAR(9)
 CONSTRAINT PK_DETCUM PRIMARY KEY CLUSTERED (DET_TIP,DET_NUM,DET_CIA,DET_ITM),
 CONSTRAINT CK_DETCUMDET_CDC CHECK ((len([DET_CDC])>(0))),
 CONSTRAINT CK_DETCUMDET_CIA CHECK ((len([DET_CIA])>(0))),
 CONSTRAINT CK_DETCUMDET_TDC CHECK ((len([DET_TDC])>(0))),
 CONSTRAINT CK_DETCUMDET_TIP CHECK ((len([DET_TIP])>(0))))
GO
