

if exists(select 1 from sys.procedures where name='sel_equ_equipos_reporte')
	drop PROCEDURE [dbo].[sel_equ_equipos_reporte];

GO

	create PROCEDURE [dbo].[sel_equ_equipos_reporte]
		@p_eid as varchar (50)='',
		@p_filtro as varchar (8000) = '1=1',
		@p_orden as varchar (8000) = 'id',
		@p_campos as varchar (8000) = '*' AS
	BEGIN
	exec ('SELECT '+ @p_campos +
	' FROM [view_equ_equipo] EQ
	inner join view_cat_catalogo_equipo_catalogo_tempario CECAT on EQ.[id_catalogo.equipo]=CECAT.[id_catalogo.equipo]
	WHERE  (EQ.eid like '''+@p_eid+'%'+''' ) AND (' + @p_filtro + ') ORDER BY ' + @p_orden)
	END

GO
