if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[qEmpleadosCarnets]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[qEmpleadosCarnets]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.qEmpleadosCarnets
AS
SELECT     C.IdEmpleado AS IdEmplado, E.TipoId, E.Codigo, E.Apellidos, E.Nombres, C.NContrato AS NCntrato, C.IdTipCon AS CodTCon, TC.TipoContrato, 
                      C.FecIngreso, C.FecVigencia, C.FecRetiro, C.Indefinido, C.IdCargo AS CodCargo, CG.Cargo, C.IdJornada AS IdJrnada, J.Jornada, C.IdArea AS CodArea, 
                      AR.Area, C.IdDep AS CodDep, D.Dependencia, C.IdInstala AS IdInstla, I.Instlacion, C.IdCia AS CodCia, CI.Compania, C.IdNom AS CodNom, 
                      TN.TipoNomina, C.TipoLiquida AS TipoLiq, C.ModPromdio, C.VrSalario, C.VrAuxTrans, C.SalMinimo, C.SalIntegral, C.FPnomina, E.Direccion AS Dirccion, 
                      E.IdLocal AS CodCiu, L.Localidad AS Ciudad, E.Telefono, E.TelMovil, E.e_mail, E.FecNacmto, E.LugarNacmto, E.TipoSangre, E.FactorRh, E.Sexo, 
                      E.IdEstCivil, ECV.EstCivil, E.IdProf AS CodProf, P.Profesion, FS.Fondo AS FondEps, FR.Fondo AS FondArp, E.EsCondtor, E.pVehiculo, E.FotoEmp, 
                      E.Observacion, E.Inactivo AS Emp_Inactivo
FROM         dbo.Emp_Contrato C INNER JOIN
                      dbo.Empleados E ON C.IdEmpleado = E.IdEmpleado INNER JOIN
                      dbo.TiposCon TC ON C.IdTipCon = TC.IdTipCon INNER JOIN
                      dbo.Cargos CG ON C.IdCargo = CG.IdCargo INNER JOIN
                      dbo.Jornadas J ON C.IdJornada = J.IdJornada INNER JOIN
                      dbo.Dependencias D ON C.IdDep = D.IdDep INNER JOIN
                      dbo.Areas AR ON C.IdArea = AR.IdArea INNER JOIN
                      dbo.Instalaciones I ON C.IdInstala = I.IdInstala INNER JOIN
                      dbo.Companias CI ON C.IdCia = CI.IdCia INNER JOIN
                      dbo.TiposNom TN ON C.IdNom = TN.IdNom INNER JOIN
                      dbo.Localidades L ON E.IdLocal = L.IdLocal INNER JOIN
                      dbo.EstadoCiv ECV ON E.IdEstCivil = ECV.IdEstado INNER JOIN
                      dbo.Profesiones P ON E.IdProf = P.IdProf INNER JOIN
                      dbo.Fondos FS ON E.IdFonEps = FS.IdFondo INNER JOIN
                      dbo.Fondos FR ON E.IdFonArp = FR.IdFondo

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

