CREATE TABLE LogTmNER ( 
IdUsuario VARCHAR(5) NOT NULL,
Item INT DEFAULT ((0)) NOT NULL,
IdPeriodo VARCHAR(8) NOT NULL,
IdEmpleado VARCHAR(16) NOT NULL,
NContrato INT DEFAULT ((0)) NOT NULL,
IdRegNom VARCHAR(30) NOT NULL,
NumLiquida INT DEFAULT ((0)) NOT NULL,
NumSemLiq INT DEFAULT ((0)) NOT NULL,
FecInicial SMALLDATETIME NOT NULL,
FecFinal SMALLDATETIME NOT NULL,
Cantidad DECIMAL(10,4) DEFAULT ((0)) NOT NULL,
CantNoRem DECIMAL(10,4) DEFAULT ((0)) NOT NULL,
VrDevengado MONEY DEFAULT ((0)) NOT NULL,
VrDeducido MONEY DEFAULT ((0)) NOT NULL,
IdDep VARCHAR(4) NOT NULL,
IdInstala VARCHAR(4) NOT NULL,
IdCCosto VARCHAR(16) NOT NULL,
IdSubCos VARCHAR(16) NOT NULL,
IdNom VARCHAR(4) NOT NULL,
VrSalario MONEY DEFAULT ((0)) NOT NULL,
VrATransMes MONEY DEFAULT ((0)) NOT NULL,
pVehiculo VARCHAR(10),
FecIniPmd SMALLDATETIME,
FecFinPmd SMALLDATETIME,
DiasVac INT DEFAULT ((0)) NOT NULL,
NPeriodos INT DEFAULT ((0)) NOT NULL,
CantRem INT DEFAULT ((0)) NOT NULL,
VrRemndo MONEY DEFAULT ((0)) NOT NULL,
TipCom VARCHAR(3),
Comprobante INT DEFAULT ((0)) NOT NULL,
IdCiaCom CHAR(2),
Observacion VARCHAR(250),
IdEstado VARCHAR(4) NOT NULL,
EsRetiro BIT DEFAULT ((0)) NOT NULL,
NLiqRet INT DEFAULT ((0)) NOT NULL,
TipoLiq CHAR(1) DEFAULT ('M') NOT NULL,
EsParcial BIT DEFAULT ((0)) NOT NULL,
FechaCrea SMALLDATETIME NOT NULL,
IdUsuNom VARCHAR(11),
CdTipoCot VARCHAR(4),
SubTipo_Cot VARCHAR(3),
Sal_Integral BIT DEFAULT ((0)) NOT NULL,
TipoIdent CHAR(1),
NotasAportante VARCHAR(250),
CantModifica INT DEFAULT ((0)),
NE_Estado INT DEFAULT ((0)) NOT NULL,
NE_Prefijo VARCHAR(20),
NE_Numero INT DEFAULT ((0)) NOT NULL,
NE_FecEnvio SMALLDATETIME,
NE_CUNE VARCHAR(500),
NE_QR IMAGE,
NE_CntAju INT DEFAULT ((0)),
NE_Ajustes VARCHAR(500)
 CONSTRAINT PK_LogTmNER PRIMARY KEY CLUSTERED (IdUsuario,Item),
 CONSTRAINT CK_LogTmNERIdCCosto CHECK ((len([IdCCosto])>(0))),
 CONSTRAINT CK_LogTmNERIdDep CHECK ((len([IdDep])>(0))),
 CONSTRAINT CK_LogTmNERIdEmpleado CHECK ((len([IdEmpleado])>(0))),
 CONSTRAINT CK_LogTmNERIdEstado CHECK ((len([IdEstado])>(0))),
 CONSTRAINT CK_LogTmNERIdInstala CHECK ((len([IdInstala])>(0))),
 CONSTRAINT CK_LogTmNERIdNom CHECK ((len([IdNom])>(0))),
 CONSTRAINT CK_LogTmNERIdPeriodo CHECK ((len([IdPeriodo])>(0))),
 CONSTRAINT CK_LogTmNERIdRegNom CHECK ((len([IdRegNom])>(0))),
 CONSTRAINT CK_LogTmNERIdSubCos CHECK ((len([IdSubCos])>(0))),
 CONSTRAINT CK_LogTmNERIdUsuario CHECK ((len([IdUsuario])>(0))),
 CONSTRAINT CK_LogTmNERTipoLiq CHECK ((len([TipoLiq])>(0))))
CREATE TABLE LogTmNERdet ( 
IdUsuario VARCHAR(5) NOT NULL,
Item INT DEFAULT ((0)) NOT NULL,
ItemDet INT DEFAULT ((0)) NOT NULL,
IdConcepto VARCHAR(4) NOT NULL,
Detalle VARCHAR(250),
CantDevg DECIMAL(10,4) DEFAULT ((0)) NOT NULL,
CantDed DECIMAL(10,4) DEFAULT ((0)) NOT NULL,
VrUnitario MONEY DEFAULT ((0)) NOT NULL,
VrTotDevg MONEY DEFAULT ((0)) NOT NULL,
VrTotDed MONEY DEFAULT ((0)) NOT NULL,
Unidad VARCHAR(10) DEFAULT ('UNIDADES'),
ClaseLiq VARCHAR(10) DEFAULT ('NOMINA') NOT NULL,
VrOrigen MONEY DEFAULT ((0)) NOT NULL,
Tarifa DECIMAL(10,4) DEFAULT ((0)) NOT NULL,
DiasCalc DECIMAL(10,4) DEFAULT ((0)) NOT NULL,
DiasNov DECIMAL(10,4) DEFAULT ((0)) NOT NULL,
CodFondo VARCHAR(8),
NPrestamo INT DEFAULT ((0)) NOT NULL,
NCuota INT DEFAULT ((0)) NOT NULL,
OrigCargue VARCHAR(10),
VrBaseLiq MONEY DEFAULT ((0)) NOT NULL,
VrBasExceso MONEY DEFAULT ((0)),
NitTercero VARCHAR(16),
HoraInicial SMALLDATETIME,
HoraFinal SMALLDATETIME,
TipoIncLab VARCHAR(20)
 CONSTRAINT PK_LogTmNERdet PRIMARY KEY CLUSTERED (IdUsuario,Item,ItemDet),
 CONSTRAINT CK_LogTmNERdetClaseLiq CHECK ((len([ClaseLiq])>(0))),
 CONSTRAINT CK_LogTmNERdetIdConcepto CHECK ((len([IdConcepto])>(0))),
 CONSTRAINT CK_LogTmNERdetIdUsuario CHECK ((len([IdUsuario])>(0))))
GO
CREATE NONCLUSTERED INDEX IX_LogTmNERIdEmpleado ON LogTmNER(IdPeriodo,IdEmpleado,NContrato)
