USE [IHSecurity]
GO

/****** Object:  View [dbo].[VST_Enlaces]    Script Date: 09/28/2016 09:08:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



ALTER VIEW [dbo].[VST_Enlaces]
AS
SELECT     Enlace_Datos.id_enla_datos, 
           Enlace_Datos.id_datos_origen, 
           Datori.descripcion AS desc_ori, 
           Datori.id_modulo AS id_modulo_ori, 
           Modori.desc_modulo AS modulo_ori, 
           Datori.base_datos AS base_datos_ori, 
           Datori.servidor AS servidor_ori,
           Datori.login AS usuario_ori,
           Datori.password AS pass_ori,
           Enlace_Datos.id_datos_destino, 
           Datdes.descripcion AS desc_dest, 
           Datdes.id_modulo AS id_modulo_dest,
           Moddes.desc_modulo AS modulo_dest, 
           Datdes.base_datos AS base_datos_dest, 
           Datdes.servidor AS servidor_dest, 
           Datdes.login AS usuario_dest,
           Datdes.password AS pass_dest,
           ISNULL(DatoriX.linked_server, '') AS linked_server_ori,
           ISNULL(DatdesX.linked_server, '') AS linked_server_dest
FROM       dbo.Enlace_Datos AS Enlace_datos 
INNER JOIN dbo.Datos  AS Datori ON Enlace_Datos.id_datos_origen  = Datori.id_datos 
INNER JOIN dbo.Datos  AS Datdes ON Enlace_Datos.id_datos_destino = Datdes.id_datos 
INNER JOIN dbo.Modulo AS Moddes ON Datdes.id_modulo = Moddes.id_modulo 
INNER JOIN dbo.Modulo AS Modori ON Datori.id_modulo = Modori.id_modulo
LEFT JOIN dbo.DatosX  AS DatoriX ON Enlace_Datos.id_datos_origen  = DatoriX.id_datos 
LEFT JOIN dbo.DatosX  AS DatdesX ON Enlace_Datos.id_datos_destino = DatdesX.id_datos 

GO
