IF OBJECT_ID('dbo.vw_fco_dir_tra') IS NOT NULL
    DROP VIEW dbo.vw_fco_dir_tra
GO
CREATE VIEW dbo.vw_fco_dir_tra
AS
SELECT
    trabajador,
    dire = Replace(IsNull(RTrim(dato_10), ' ') + ' ' +
           IsNull(LTrim(RTrim(SubString(dato_09, 8, 50))), ' '), ',', ' '),
    mpio = IsNull(Left(dato_09, 3), ''),
    dpto = IsNull(SubString(dato_09, 5, 2), '')
FROM
    inf_soc_trabajador
WHERE
    indice_inf_soc = '2VV_UBICAC'
GO
GRANT SELECT ON dbo.vw_fco_dir_tra TO PUBLIC
GO
