if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsEmpleados]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsEmpleados]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpEmpleados]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paUpEmpleados]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryEmpleadosDso]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryEmpleadosDso]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryEmp_ContratoDso]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryEmp_ContratoDso]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQrySectoresEcoDso]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQrySectoresEcoDso]
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryEmp_ContratoDso] @pmIdEmpleado VARCHAR(16)=Null,@pmIndefinido BIT=Null,@pmIdTipCon VARCHAR(4)=Null,@pmIdCargo VARCHAR(4)=Null,@pmIdDep VARCHAR(4)=Null
,@pmIdArea VARCHAR(4)=Null,@pmIdInstala VARCHAR(4)=Null,@pmIdCCosto VARCHAR(16)=Null,@pmIdSubCos VARCHAR(16)=Null,@pmIdNom VARCHAR(4)=Null,@pmTipoLiquida CHAR(1)=Null
,@pmSalMinimo BIT=Null,@pmSalIntegral BIT=Null,@pmFPnomina VARCHAR(10)=Null,@pmModoRet INT=Null,@pmIdClase VARCHAR(4)=Null,@pmInactivo BIT=Null,@pmIdEstado VARCHAR(4)=Null
,@pmNContrato INT=Null,@pmFecIngresoIni SMALLDATETIME=Null,@pmFecIngresoFin SMALLDATETIME=Null,@pmATFinMes BIT=Null,@pmSegFinMes BIT=Null,@pmDchDotacion BIT=Null
--parametros de empleados
,@pmTipoSangre CHAR(2)=Null,@pmFactorRh CHAR(1)=Null,@pmSexo CHAR(1)=Null,@pmIdEstCivil VARCHAR(4)=Null,@pmClaseLib INT=Null, @pmIdProf VARCHAR(4)=Null,@pmTallaCam VARCHAR(5)=Null
,@pmTallaPan VARCHAR(5)=Null,@pmTallaZap VARCHAR(5)=Null,@pmIdFonPen VARCHAR(8)=Null,@pmIdFonEps VARCHAR(8)=Null,@pmIdFonArp VARCHAR(8)=Null,@pmIdFonCes VARCHAR(8)=Null,@pmIdCajaCom VARCHAR(8)=Null
,@pmIdBanco VARCHAR(4)=Null,@pmEmp_IdEstado VARCHAR(4)=Null,@pmEmp_Inactivo BIT=Null,@pmEsCondtor BIT=Null,@pmFecNacmtoIni SMALLDATETIME=Null,@pmFecNacmtoFin SMALLDATETIME=Null
 AS 

 SELECT  C.IdEmpleado AS IdEmplado,Apellidos,Nombres,C.NContrato AS NCntrato,C.IdTipCon AS CodTCon,TipoContrato,FecIngreso,FecVigencia,FecRetiro,Indefinido,C.IdCargo AS CodCargo,Cargo
,C.IdJornada AS IdJrnada,Jornada,C.IdArea AS CodArea,Area,C.IdDep AS CodDep,Dependencia,C.IdInstala AS IdInstla,Instlacion,C.IdCCosto AS IdCCto,CCosto,C.IdSubCos AS IdSubcen,SubCosto,C.IdCia AS CodCia,Compania
,C.IdClase AS CodClaRie,ClaseRiesgo,Tarifa,TipoTrabj,C.IdNom AS CodNom,TipoNomina,C.TipoLiquida AS TipoLiq,ModPromdio,VrSalario,VrAuxTrans,SalMinimo,SalIntegral,FPnomina,ModoRet,FecAfiSeg,ATFinMes,SegFinMes,FspFinmes,DenyPEN,DenyEPS,DenyARP
,DenyCaj,DenyCes,DenyPri,DenyVac,DenyHex,DenyDcto,BasePrest,BaseSeg,DchDotacion,DchCafeteria,Reclmto,Notas,DsoSabado,FecFinPrueba,TipoPrendDot,TipoMedSent,BenefPacto,C.TipoTraspaso,C.FechaTraspaso,C.ContratoRef
,C.IdEstado AS IdEstdCon,EC.Estado AS EstdoCon,EC.NColor AS ConEstcolor,C.Inactivo AS Inactvo,C.FecAdd AS Fec_Add,C.FecUpdate AS Fec_Update,C.IdUsuario AS IdUsuari,U.Usuario AS Con_Usuario,IdCot,C.IdGrupo AS GrupAR,VrUpc
--empleados
,E.Direccion AS Dirccion,E.IdLocal AS CodCiu,L.Localidad AS Ciudad,Telefono,TelMovil,e_mail,VvdaPropia,FecNacmto,LugarNacmto,TipoSangre,FactorRh,Sexo,IdEstCivil,EstCivil,NHijos,TallaCam,TallaPan,TallaZap,UsaGafas,E.IdProf AS CodProf,Profesion
,LibMilitar,ClaseLib,FechaLib,DistMil,CertJudicial,FecJudicial,VigJudicial,Pasporte,VigPaspte,Licencia,E.IdLugar AS CodLugar,LugarLic,CatLicencia,FecLicencia,VigLicencia,IdLugarCed,LC.Localidad AS LugarCed,Conyugue,ConyFecNac,ConyTrabaja
,ConyEmpresa,ConyCargo,ConyFing,ConyTel,E.IdClase AS CodClase,ClaseCuenta,NumCuenta,E.IdBanco AS CodBco,Banco,IdFonPen,FP.Fondo AS FondPen,IdFonEps,FS.Fondo AS FondEps,IdFonArp,FR.Fondo AS FondArp,IdFonCes,FC.Fondo AS FondCes
,IdCajaCom,CC.Fondo AS CajaComp,FecVincula,FecUltAum,FecUltCes,FecUltPri,FecUltVac,FecUltDot,FecUltExm,FecUltCap,NCAnterior,FecIngAnt,FecRetAnt,EsCondtor,pVehiculo,FotoEmp,FotoLic,FotoFirma,Observacion,E.IdEstado AS Emp_IdEstado
,ET.Estado AS Emp_estado,E.Inactivo AS Emp_Inactivo,TipoId,Codigo,ET.NColor AS EmpEstcolor,E.FechaAdd AS EmpFecAdd,E.FechaUpdate AS EmpFecupd,E.IdUsuario AS Emp_IdUsuario,UE.Usuario AS Emp_Usuario,SubTipoCot
 FROM Emp_Contrato AS C INNER JOIN Empleados AS E ON C.IdEmpleado=E.IdEmpleado INNER JOIN TiposCon AS TC ON C.IdTipCon=TC.IdTipCon
 INNER JOIN Cargos AS CG ON C.IdCargo=CG.IdCargo INNER JOIN Jornadas AS J ON C.IdJornada=J.IdJornada
 INNER JOIN Dependencias AS D ON C.IdDep=D.IdDep  INNER JOIN Areas AS AR ON C.IdArea=AR.IdArea
 INNER JOIN Instalaciones AS I ON C.IdInstala=I.IdInstala  INNER JOIN CentroCosto AS CO ON C.IdCCosto=CO.IdCCosto
 INNER JOIN SubCentros AS SC ON C.IdSubCos=SC.IdSubCos INNER JOIN Companias AS CI ON C.IdCia=CI.IdCia
 INNER JOIN TiposNom AS TN ON C.IdNom=TN.IdNom INNER JOIN EstadoDoc AS EC ON C.IdEstado=EC.IdEstado 
 INNER JOIN adm_Usuarios AS U ON C.IdUsuario=U.IdUsuario  INNER JOIN ClaseRie AS CR ON C.IdClase=CR.IdClase
 INNER JOIN Localidades AS L ON E.IdLocal=L.IdLocal INNER JOIN Localidades AS LC ON E.IdLugarCed=LC.IdLocal
 INNER JOIN EstadoCiv AS ECV ON E.IdEstCivil=ECV.IdEstado INNER JOIN ExpLicencias AS LL ON E.IdLugar=LL.IdLugar
 INNER JOIN Profesiones AS P ON E.IdProf=P.IdProf INNER JOIN Fondos AS FP ON E.IdFonPen=FP.IdFondo
 INNER JOIN Fondos AS FS ON E.IdFonEps=FS.IdFondo INNER JOIN Fondos AS FR ON E.IdFonArp=FR.IdFondo
 INNER JOIN Fondos AS FC ON E.IdFonCes=FC.IdFondo INNER JOIN Fondos AS CC ON E.IdCajaCom=CC.IdFondo
 INNER JOIN ClaseCta AS CT ON E.IdClase=CT.IdClase  INNER JOIN Bancos AS B ON E.IdBanco=B.IdBanco
 INNER JOIN EstadoTer AS ET ON E.IdEstado=ET.IdEstado INNER JOIN adm_Usuarios AS UE ON E.IdUsuario=UE.IdUsuario
 WHERE C.IdEmpleado LIKE ISNULL(@pmIdEmpleado,'%')  AND C.IdTipCon LIKE ISNULL(@pmIdTipCon,'%') AND C.IdCargo LIKE ISNULL(@pmIdCargo,'%')
 AND C.IdDep LIKE ISNULL(@pmIdDep,'%') AND C.IdArea LIKE ISNULL(@pmIdArea,'%') AND C.IdInstala LIKE ISNULL(@pmIdInstala,'%')
 AND C.IdCCosto LIKE ISNULL(@pmIdCCosto,'%') AND C.IdSubCos LIKE ISNULL(@pmIdSubCos,'%')  AND C.IdNom LIKE ISNULL(@pmIdNom,'%') 
 AND C.TipoLiquida LIKE ISNULL(@pmTipoLiquida,'%') AND FPnomina LIKE ISNULL(@pmFPnomina,'%')  AND C.IdClase LIKE ISNULL(@pmIdClase,'%')
 AND C.IdEstado LIKE ISNULL(@pmIdEstado,'%') 
 AND (C.NContrato>=ISNULL(@pmNContrato,0)  AND C.NContrato<=ISNULL(@pmNContrato,2147483647)) 
 AND (ModoRet>=ISNULL(@pmModoRet,0)  AND ModoRet<=ISNULL(@pmModoRet,2147483647)) 
 AND (SalMinimo=ISNULL(@pmSalMinimo,0) or SalMinimo=ISNULL(@pmSalMinimo,1))
 AND (Indefinido=ISNULL(@pmIndefinido,0) or Indefinido=ISNULL(@pmIndefinido,1))
 AND (SalIntegral=ISNULL(@pmSalIntegral,0) or SalIntegral=ISNULL(@pmSalIntegral,1))
 AND (C.Inactivo=ISNULL(@pmInactivo,0) or C.Inactivo=ISNULL(@pmInactivo,1))
 AND (ATFinMes=ISNULL(@pmATFinMes,0) or ATFinMes=ISNULL(@pmATFinMes,1))
 AND (SegFinMes=ISNULL(@pmSegFinMes,0) or SegFinMes=ISNULL(@pmSegFinMes,1))
 AND (DchDotacion=ISNULL(@pmDchDotacion,0) or DchDotacion=ISNULL(@pmDchDotacion,1))
 AND (FecIngreso>=ISNULL(@pmFecIngresoIni,CAST('19100101' AS SMALLDATETIME)) AND FecIngreso<=ISNULL(@pmFecIngresoFin,CAST('20781230' AS SMALLDATETIME)))
 AND TipoSangre LIKE ISNULL(@pmTipoSangre,'%%') AND FactorRh LIKE ISNULL(@pmFactorRh,'%') AND Sexo LIKE ISNULL(@pmSexo,'%')
 AND IdEstCivil LIKE ISNULL(@pmIdEstCivil,'%') AND E.IdProf LIKE ISNULL(@pmIdProf,'%') AND TallaCam LIKE ISNULL(@pmTallaCam,'%%')
 AND TallaPan LIKE ISNULL(@pmTallaPan,'%%') AND TallaZap LIKE ISNULL(@pmTallaZap,'%%') AND IdFonPen LIKE ISNULL(@pmIdFonPen,'%')
 AND IdFonCes LIKE ISNULL(@pmIdFonCes,'%') AND IdFonArp LIKE ISNULL(@pmIdFonArp,'%') AND IdFonEps LIKE ISNULL(@pmIdFonEps,'%')
 AND IdCajaCom LIKE ISNULL(@pmIdCajaCom ,'%') AND E.IdBanco LIKE ISNULL(@pmIdBanco,'%') AND E.IdEstado LIKE ISNULL(@pmEmp_IdEstado,'%')
 AND (ClaseLib>=ISNULL(@pmClaseLib,0)  AND ClaseLib<=ISNULL(@pmClaseLib,2147483647)) 
 AND (E.Inactivo=ISNULL(@pmEmp_Inactivo,0) or E.Inactivo=ISNULL(@pmEmp_Inactivo,1))
 AND (EsCondtor=ISNULL(@pmEsCondtor,0) or EsCondtor=ISNULL(@pmEsCondtor,1))
 AND (FecNacmto>=ISNULL(@pmFecNacmtoIni,CAST('19100101' AS SMALLDATETIME)) AND FecNacmto<=ISNULL(@pmFecNacmtoFin,CAST('20781230' AS SMALLDATETIME)))
 ORDER BY Apellidos,Nombres,C.NContrato
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQryEmpleadosDso] @pmTipoSangre CHAR(2)=Null,@pmFactorRh CHAR(1)=Null,@pmSexo CHAR(1)=Null,@pmIdEstCivil VARCHAR(4)=Null,@pmClaseLib INT=Null, @pmIdProf VARCHAR(4)=Null,@pmTallaCam VARCHAR(5)=Null
,@pmTallaPan VARCHAR(5)=Null,@pmTallaZap VARCHAR(5)=Null,@pmIdFonPen VARCHAR(8)=Null,@pmIdFonEps VARCHAR(8)=Null,@pmIdFonArp VARCHAR(8)=Null,@pmIdFonCes VARCHAR(8)=Null,@pmIdCajaCom VARCHAR(8)=Null,@pmIdBanco VARCHAR(4)=Null
,@pmNContrato INT=Null,@pmIdEstado VARCHAR(4)=Null,@pmInactivo BIT=Null,@pmEsCondtor BIT=Null,@pmFecNacmtoIni SMALLDATETIME=Null,@pmFecNacmtoFin SMALLDATETIME=Null,@pmIdEmpleado VARCHAR(16)=Null
 AS 
 SELECT Apellidos,Nombres,TipoId,IdEmpleado,IdLugarCed,LC.Localidad AS LugarCed,E.Direccion AS Dirccion,E.IdLocal AS CodCiu,L.Localidad AS Ciudad,Telefono,TelMovil,e_mail,VvdaPropia,FecNacmto,LugarNacmto,TipoSangre,FactorRh,Sexo,IdEstCivil,EstCivil,NHijos,LibMilitar,ClaseLib
,FechaLib,DistMil,CertJudicial,FecJudicial,VigJudicial,Pasporte,VigPaspte,Licencia,E.IdLugar AS CodLugar,LugarLic,CatLicencia,FecLicencia,VigLicencia,E.IdProf AS CodProf,Profesion,TallaCam,TallaPan,TallaZap,UsaGafas,Conyugue,ConyFecNac,ConyTrabaja,ConyEmpresa,ConyCargo
,ConyFing,ConyTel,IdFonPen,FP.Fondo AS FondPen,IdFonEps,FS.Fondo AS FondEps,IdFonArp,FR.Fondo AS FondArp,IdFonCes,FC.Fondo AS FondCes,IdCajaCom,CC.Fondo AS CajaComp,E.IdClase AS CodClase,ClaseCuenta,NumCuenta,E.IdBanco AS CodBco,Banco,CdLocCue,NContrato,FecVincula
,FecUltAum,FecUltCes,FecUltPri,FecUltVac,FecUltIng,FecUltRet,FecUltDot,FecUltExm,FecUltCap,FecUltParc,NCAnterior,FecIngAnt,FecRetAnt,EsCondtor,pVehiculo,DecRenta,NivelEduc,FotoEmp,FotoLic,FotoFirma,Observacion,E.IdEstado AS IdEstdo,Estado,E.Inactivo AS Inctivo,Dv,Codigo,NColor,FechaAdd,FechaUpdate,E.IdUsuario AS IdUsuari,Usuario,CdFonAvp
 FROM Empleados AS E INNER JOIN Localidades AS L ON E.IdLocal=L.IdLocal INNER JOIN Localidades AS LC ON E.IdLugarCed=LC.IdLocal
 INNER JOIN EstadoCiv AS EC ON E.IdEstCivil=EC.IdEstado INNER JOIN ExpLicencias AS LL ON E.IdLugar=LL.IdLugar
 INNER JOIN Profesiones AS P ON E.IdProf=P.IdProf INNER JOIN Fondos AS FP ON E.IdFonPen=FP.IdFondo
 INNER JOIN Fondos AS FS ON E.IdFonEps=FS.IdFondo INNER JOIN Fondos AS FR ON E.IdFonArp=FR.IdFondo
 INNER JOIN Fondos AS FC ON E.IdFonCes=FC.IdFondo INNER JOIN Fondos AS CC ON E.IdCajaCom=CC.IdFondo
 INNER JOIN ClaseCta AS CT ON E.IdClase=CT.IdClase  INNER JOIN Bancos AS B ON E.IdBanco=B.IdBanco
 INNER JOIN EstadoTer AS ET ON E.IdEstado=ET.IdEstado INNER JOIN adm_Usuarios AS U ON E.IdUsuario=U.IdUsuario
 WHERE IdEmpleado LIKE ISNULL(@pmIdEmpleado,'%')  AND TipoSangre LIKE ISNULL(@pmTipoSangre,'%%') AND FactorRh LIKE ISNULL(@pmFactorRh,'%') AND Sexo LIKE ISNULL(@pmSexo,'%')
 AND IdEstCivil LIKE ISNULL(@pmIdEstCivil,'%') AND E.IdProf LIKE ISNULL(@pmIdProf,'%') AND TallaCam LIKE ISNULL(@pmTallaCam,'%%')
 AND TallaPan LIKE ISNULL(@pmTallaPan,'%%') AND TallaZap LIKE ISNULL(@pmTallaZap,'%%') AND IdFonPen LIKE ISNULL(@pmIdFonPen,'%')
 AND IdFonCes LIKE ISNULL(@pmIdFonCes,'%') AND IdFonArp LIKE ISNULL(@pmIdFonArp,'%') AND IdFonEps LIKE ISNULL(@pmIdFonEps,'%')
 AND IdCajaCom LIKE ISNULL(@pmIdCajaCom ,'%') AND E.IdBanco LIKE ISNULL(@pmIdBanco,'%') AND E.IdEstado LIKE ISNULL(@pmIdEstado,'%')
 AND (ClaseLib>=ISNULL(@pmClaseLib,0)  AND ClaseLib<=ISNULL(@pmClaseLib,2147483647)) 
 AND (NContrato>=ISNULL(@pmNContrato,-1)  AND NContrato<=ISNULL(@pmNContrato,2147483647))
 AND (E.Inactivo=ISNULL(@pmInactivo,0) or E.Inactivo=ISNULL(@pmInactivo,1))
 AND (EsCondtor=ISNULL(@pmEsCondtor,0) or EsCondtor=ISNULL(@pmEsCondtor,1))
 AND (FecNacmto>=ISNULL(@pmFecNacmtoIni,CAST('19100101' AS SMALLDATETIME)) AND FecNacmto<=ISNULL(@pmFecNacmtoFin,CAST('20781230' AS SMALLDATETIME)))
 ORDER BY Apellidos,Nombres
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paInsEmpleados] @pmIdEmpleado VARCHAR(16),@pmApellidos VARCHAR(80),@pmNombres VARCHAR(70),@pmCodigo VARCHAR(16),@pmTipoId CHAR(1),@pmDv CHAR(1),@pmIdLugarCed VARCHAR(8),@pmDireccion VARCHAR(250),@pmIdLocal VARCHAR(8),@pmTelefono VARCHAR(20),@pmTelMovil VARCHAR(20),@pme_mail VARCHAR(100),@pmVvdaPropia BIT, @pmFecNacmto SMALLDATETIME,@pmLugarNacmto VARCHAR(30)
,@pmTipoSangre CHAR(2),@pmFactorRh CHAR(1),@pmSexo CHAR(1),@pmIdEstCivil VARCHAR(4),@pmNHijos INT,@pmLibMilitar VARCHAR(25),@pmClaseLib INT,@pmFechaLib SMALLDATETIME,@pmDistMil VARCHAR(10),@pmCertJudicial VARCHAR(25),@pmFecJudicial SMALLDATETIME,@pmVigJudicial SMALLDATETIME,@pmPasporte VARCHAR(25),@pmVigPaspte SMALLDATETIME,@pmLicencia VARCHAR(25),@pmIdLugar VARCHAR(8)
,@pmCatLicencia INT,@pmFecLicencia SMALLDATETIME,@pmVigLicencia SMALLDATETIME,@pmIdProf VARCHAR(4),@pmTallaCam VARCHAR(5),@pmTallaPan VARCHAR(5),@pmTallaZap VARCHAR(5),@pmUsaGafas BIT,@pmConyugue VARCHAR(50),@pmConyFecNac SMALLDATETIME,@pmConyTrabaja BIT,@pmConyEmpresa VARCHAR(50),@pmConyCargo VARCHAR(20),@pmConyFing SMALLDATETIME,@pmConyTel VARCHAR(20),@pmIdFonPen VARCHAR(8)
,@pmIdFonEps VARCHAR(8),@pmIdFonArp VARCHAR(8),@pmIdFonCes VARCHAR(8),@pmIdCajaCom VARCHAR(8),@pmCdFonAvp VARCHAR(8),@pmIdClase VARCHAR(4),@pmNumCuenta VARCHAR(25),@pmIdBanco VARCHAR(4),@pmNContrato INT,@pmFecVincula SMALLDATETIME,@pmFecUltAum SMALLDATETIME,@pmFecUltCes SMALLDATETIME,@pmFecUltPri SMALLDATETIME,@pmFecUltVac SMALLDATETIME,@pmFecUltIng SMALLDATETIME,@pmFecUltRet SMALLDATETIME,@pmFecUltDot SMALLDATETIME
,@pmFecUltExm SMALLDATETIME,@pmFecUltCap SMALLDATETIME,@pmNCAnterior INT,@pmFecIngAnt SMALLDATETIME,@pmFecRetAnt SMALLDATETIME,@pmFotoEmp VARCHAR(30),@pmFotoLic VARCHAR(30),@pmFotoFirma VARCHAR(30),@pmEsCondtor BIT,@pmpVehiculo VARCHAR(10),@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmInactivo BIT,@pmCdLocCue VARCHAR(8),@pmFecUltParc SMALLDATETIME,@pmDecRenta INT,@pmNivelEduc VARCHAR(4),@pmFechaAdd SMALLDATETIME,@pmIdUsuario VARCHAR(11)
 AS 
 INSERT INTO Empleados (IdEmpleado,Apellidos,Nombres,Codigo,TipoId,Dv,IdLugarCed,Direccion,IdLocal,Telefono,TelMovil,e_mail,VvdaPropia,FecNacmto,LugarNacmto,TipoSangre,FactorRh,Sexo,IdEstCivil,NHijos,LibMilitar,ClaseLib,FechaLib,DistMil,CertJudicial,FecJudicial,VigJudicial,Pasporte,VigPaspte,Licencia,IdLugar,CatLicencia,FecLicencia,VigLicencia,IdProf,TallaCam,TallaPan,TallaZap,UsaGafas,Conyugue,ConyFecNac,ConyTrabaja,ConyEmpresa,ConyCargo,ConyFing,ConyTel,IdFonPen
,IdFonEps,IdFonArp,IdFonCes,IdCajaCom,IdClase,NumCuenta,IdBanco,NContrato,FecVincula,FecUltAum,FecUltCes,FecUltPri,FecUltVac,FecUltIng,FecUltRet,FecUltDot,FecUltExm,FecUltCap,FecUltParc,FotoEmp,FotoLic,FotoFirma,NCAnterior,FecIngAnt,FecRetAnt,EsCondtor,pVehiculo,Observacion,CdFonAvp,IdEstado,Inactivo,CdLocCue,FechaAdd,IdUsuario,DecRenta,NivelEduc)
 VALUES (@pmIdEmpleado,@pmApellidos,@pmNombres,@pmCodigo,@pmTipoId,@pmDv,@pmIdLugarCed,@pmDireccion,@pmIdLocal,@pmTelefono,@pmTelMovil,@pme_mail,@pmVvdaPropia,@pmFecNacmto,@pmLugarNacmto,@pmTipoSangre,@pmFactorRh,@pmSexo,@pmIdEstCivil,@pmNHijos,@pmLibMilitar,@pmClaseLib,@pmFechaLib,@pmDistMil,@pmCertJudicial,@pmFecJudicial,@pmVigJudicial,@pmPasporte,@pmVigPaspte,@pmLicencia,@pmIdLugar,@pmCatLicencia,@pmFecLicencia,@pmVigLicencia
,@pmIdProf,@pmTallaCam,@pmTallaPan,@pmTallaZap,@pmUsaGafas,@pmConyugue,@pmConyFecNac,@pmConyTrabaja,@pmConyEmpresa,@pmConyCargo,@pmConyFing,@pmConyTel,@pmIdFonPen,@pmIdFonEps,@pmIdFonArp,@pmIdFonCes,@pmIdCajaCom,@pmIdClase,@pmNumCuenta,@pmIdBanco,@pmNContrato,@pmFecVincula,@pmFecUltAum,@pmFecUltCes,@pmFecUltPri,@pmFecUltVac,@pmFecUltIng,@pmFecUltRet,@pmFecUltDot,@pmFecUltExm,@pmFecUltCap,@pmFecUltParc,@pmFotoEmp,@pmFotoLic
,@pmFotoFirma,@pmNCAnterior,@pmFecIngAnt,@pmFecRetAnt,@pmEsCondtor,@pmpVehiculo,@pmObservacion,@pmCdFonAvp,@pmIdEstado,@pmInactivo,@pmCdLocCue,@pmFechaAdd,@pmIdUsuario,@pmDecRenta,@pmNivelEduc)
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paUpEmpleados] @pmIdEmpleado VARCHAR(16),@pmApellidos VARCHAR(80),@pmNombres VARCHAR(70),@pmCodigo VARCHAR(16),@pmTipoId CHAR(1),@pmDv CHAR(1),@pmIdLugarCed VARCHAR(8),@pmDireccion VARCHAR(250),@pmIdLocal VARCHAR(8),@pmTelefono VARCHAR(20),@pmTelMovil VARCHAR(20),@pme_mail VARCHAR(100),@pmVvdaPropia BIT,@pmFecNacmto SMALLDATETIME,@pmLugarNacmto VARCHAR(30),@pmTipoSangre CHAR(2),@pmFactorRh CHAR(1),@pmSexo CHAR(1)
,@pmIdEstCivil VARCHAR(4),@pmNHijos INT,@pmLibMilitar VARCHAR(25),@pmClaseLib INT,@pmFechaLib SMALLDATETIME,@pmDistMil VARCHAR(10),@pmCertJudicial VARCHAR(25),@pmFecJudicial SMALLDATETIME,@pmVigJudicial SMALLDATETIME,@pmPasporte VARCHAR(25),@pmVigPaspte SMALLDATETIME,@pmLicencia VARCHAR(25),@pmIdLugar VARCHAR(8),@pmCatLicencia INT,@pmFecLicencia SMALLDATETIME,@pmVigLicencia SMALLDATETIME,@pmIdProf VARCHAR(4),@pmTallaCam VARCHAR(5)
,@pmTallaPan VARCHAR(5),@pmTallaZap VARCHAR(5),@pmUsaGafas BIT,@pmConyugue VARCHAR(50),@pmConyFecNac SMALLDATETIME,@pmConyTrabaja BIT,@pmConyEmpresa VARCHAR(50),@pmConyCargo VARCHAR(20),@pmConyFing SMALLDATETIME,@pmConyTel VARCHAR(20),@pmIdFonPen VARCHAR(8),@pmIdFonEps VARCHAR(8),@pmIdFonArp VARCHAR(8),@pmIdFonCes VARCHAR(8),@pmIdCajaCom VARCHAR(8),@pmCdFonAvp VARCHAR(8),@pmIdClase VARCHAR(4),@pmNumCuenta VARCHAR(25),@pmIdBanco VARCHAR(4),@pmNContrato INT,@pmFecVincula SMALLDATETIME
,@pmFecUltAum SMALLDATETIME,@pmFecUltCes SMALLDATETIME,@pmFecUltPri SMALLDATETIME,@pmFecUltVac SMALLDATETIME,@pmFecUltIng SMALLDATETIME,@pmFecUltRet SMALLDATETIME,@pmFecUltDot SMALLDATETIME,@pmFecUltExm SMALLDATETIME,@pmFecUltCap SMALLDATETIME,@pmNCAnterior INT,@pmFecIngAnt SMALLDATETIME,@pmFecRetAnt SMALLDATETIME,@pmFotoEmp VARCHAR(30),@pmFotoLic VARCHAR(30),@pmFotoFirma VARCHAR(30),@pmEsCondtor BIT,@pmpVehiculo VARCHAR(10)
,@pmObservacion VARCHAR(250),@pmIdEstado VARCHAR(4),@pmInactivo BIT,@pmCdLocCue VARCHAR(8),@pmFecUltParc SMALLDATETIME,@pmDecRenta INT,@pmNivelEduc VARCHAR(4),@pmFechaUpdate SMALLDATETIME
 AS 
 UPDATE Empleados SET Apellidos=@pmApellidos,Nombres=@pmNombres,Codigo=@pmCodigo,TipoId=@pmTipoId,Dv=@pmDv,IdLugarCed=@pmIdLugarCed,Direccion=@pmDireccion,IdLocal=@pmIdLocal,Telefono=@pmTelefono,TelMovil=@pmTelMovil,e_mail=@pme_mail,VvdaPropia=@pmVvdaPropia,FecNacmto=@pmFecNacmto,LugarNacmto=@pmLugarNacmto,TipoSangre=@pmTipoSangre,FactorRh=@pmFactorRh,Sexo=@pmSexo,IdEstCivil=@pmIdEstCivil,NHijos=@pmNHijos,LibMilitar=@pmLibMilitar,ClaseLib=@pmClaseLib,FechaLib=@pmFechaLib,DistMil=@pmDistMil
,CertJudicial=@pmCertJudicial,FecJudicial=@pmFecJudicial,VigJudicial=@pmVigJudicial,Pasporte=@pmPasporte,VigPaspte=@pmVigPaspte,Licencia=@pmLicencia,IdLugar=@pmIdLugar,CatLicencia=@pmCatLicencia,FecLicencia=@pmFecLicencia,VigLicencia=@pmVigLicencia,IdProf=@pmIdProf,TallaCam=@pmTallaCam,TallaPan=@pmTallaPan,TallaZap=@pmTallaZap,UsaGafas=@pmUsaGafas,Conyugue=@pmConyugue,ConyFecNac=@pmConyFecNac,ConyTrabaja=@pmConyTrabaja,ConyEmpresa=@pmConyEmpresa,ConyCargo=@pmConyCargo,FecVincula=@pmFecVincula
,ConyFing=@pmConyFing,ConyTel=@pmConyTel,IdFonPen=@pmIdFonPen,IdFonEps=@pmIdFonEps,IdFonArp=@pmIdFonArp,IdFonCes=@pmIdFonCes,IdCajaCom=@pmIdCajaCom,IdClase=@pmIdClase,NumCuenta=@pmNumCuenta,IdBanco=@pmIdBanco,NContrato=@pmNContrato,FecUltAum=@pmFecUltAum,FecUltCes=@pmFecUltCes,FecUltPri=@pmFecUltPri,FecUltVac=@pmFecUltVac,FecUltIng=@pmFecUltIng,FecUltRet=@pmFecUltRet,FecUltDot=@pmFecUltDot,FecUltExm=@pmFecUltExm,FecUltCap=@pmFecUltCap,FotoEmp=@pmFotoEmp,CdFonAvp=@pmCdFonAvp
,NCAnterior=@pmNCAnterior, FotoLic=@pmFotoLic,FotoFirma=@pmFotoFirma,pVehiculo=@pmpVehiculo,Observacion=@pmObservacion,IdEstado=@pmIdEstado,Inactivo=@pmInactivo,EsCondtor=@pmEsCondtor,FecIngAnt=@pmFecIngAnt,FecRetAnt=@pmFecRetAnt,CdLocCue=@pmCdLocCue,FecUltParc=@pmFecUltParc,DecRenta=@pmDecRenta,FechaUpdate=@pmFechaUpdate,NivelEduc=@pmNivelEduc
 WHERE IdEmpleado=@pmIdEmpleado
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[paQrySectoresEcoDso] 
 AS 
  SELECT IdSector,SectorEco,IdSector+' '+SectorEco AS DsSector
  FROM SectoresEco
  WHERE Inactivo=0
  ORDER BY IdSector
GO
