IF  EXISTS (SELECT object_id FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_checklistTodas]')) DROP VIEW [dbo].[v_checklistTodas]
GO

CREATE VIEW [dbo].[v_checklistTodas]
AS
	SELECT 
			CLA.id_atributo id,
			CLA.cat_atributo_atributo as item,
			SA.seccionAtributo as seccion,
			CLA.cat_atributo_id_tipoAtributo as tipo,
			dbo.f_opcionesAtributo(CLA.id_atributo,1) as IDsOpciones,
			dbo.f_opcionesAtributo(CLA.id_atributo,0) as textosOpciones,
			CLA.cat_atributo_esVariable as esVariable,
			CLA.orden as orden,
			'NI' as rango,
			CLA.cat_atributo_esObligatorio as obligatorio,
			CLA.id_pruebaChecklist as id_lista
		FROM view_cat_pruebaCheckList_atributo CLA
			INNER JOIN cat_seccionAtributo SA on SA.id= CLA.cat_atributo_id_seccionAtributo
			INNER JOIN gen_unidad UNI on UNI.id=CLA.cat_atributo_id_unidad
		WHERE
			CLA.active = 1
GO


