DROP VIEW [dbo].[view_cat_atributo]
GO
CREATE  VIEW [dbo].[view_cat_atributo] AS
SELECT 	[cat_atributo].[id] AS [id],
		[cat_atributo].[uid] AS [uid],
		[cat_atributo].[eid] AS [eid],
		[cat_atributo].[id_usuario_modifico] AS [id_usuario_modifico],
		[cat_atributo].[id_usuario_creo] AS [id_usuario_creo],
		[cat_atributo].[fechaModificacion] AS [fechaModificacion],
		[cat_atributo].[fechaCreacion] AS [fechaCreacion],
		[cat_atributo].[active] AS [active],
		[cat_atributo].[atributo] AS [atributo],
		[cat_atributo].[atributo_codigo] AS [atributo_codigo],
		[cat_atributo].[nombreControl] AS [nombreControl],
		[cat_atributo].[esVariable] AS [esVariable],
		[cat_atributo].[resaltado] AS [resaltado],
		[cat_atributo].[valorMinimo] AS [valorMinimo],
		[cat_atributo].[ValorMaximo] AS [ValorMaximo],
		[cat_atributo].[id_seccionAtributo] AS [id_seccionAtributo],
[cat_seccionAtributo].[seccionAtributo] as [cat_seccionAtributo_seccionAtributo],
[cat_seccionAtributo].[seccionAtributo_codigo] as [cat_seccionAtributo_seccionAtributo_codigo],
[cat_seccionAtributo].[orden] as [cat_seccionAtributo_orden],
[cat_seccionAtributo].[id_usoSeccionAtributo] as [cat_seccionAtributo_id_usoSeccionAtributo],
		[cat_atributo].[id_tipoAtributo] AS [id_tipoAtributo],
[equ_tipoAtributo].[tipoAtributo] as [equ_tipoAtributo_tipoAtributo],
[equ_tipoAtributo].[tipoAtributo_codigo] as [equ_tipoAtributo_tipoAtributo_codigo],
[equ_tipoAtributo].[prefijoControl] as [equ_tipoAtributo_prefijoControl],
		[cat_atributo].[id_unidad] AS [id_unidad],
[gen_unidad].[unidad] as [gen_unidad_unidad],
[gen_unidad].[unidad_codigo] as [gen_unidad_unidad_codigo],
		[cat_atributo].[esObligatorio] AS [esObligatorio],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [cat_atributo]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cat_atributo].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cat_atributo].[id_usuario_creo]
	INNER JOIN [cat_seccionAtributo] ON [cat_seccionAtributo].id=[cat_atributo].[id_seccionAtributo]
	INNER JOIN [equ_tipoAtributo] ON [equ_tipoAtributo].id=[cat_atributo].[id_tipoAtributo]
	INNER JOIN [gen_unidad] ON [gen_unidad].id=[cat_atributo].[id_unidad]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [cat_atributo].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1
WHERE [cat_atributo].active=1
GO


