
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_cat_catalogos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cat_catalogos]
GO
CREATE PROCEDURE [dbo].[sel_cat_catalogos]
	
	@p_filtro as varchar (max) = '1=1',
	@p_orden as varchar (8000) = 'id',
	@p_campos as varchar (8000) = '*' AS
BEGIN
exec ('SELECT '+ @p_campos +
' FROM [view_cat_catalogo]
WHERE (' + @p_filtro + ') ORDER BY ' + @p_orden)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_cat_catalogos_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cat_catalogos_m]
GO
CREATE PROCEDURE [dbo].[sel_cat_catalogos_m]
	@p_eid as varchar (50)='',
	@p_filtro as varchar (max) = '1=1',
	@p_orden as varchar (8000) = 'id',
	@p_campos as varchar (8000) = '*' AS
BEGIN
exec ('SELECT '+ @p_campos +
' FROM [view_cat_catalogo]
WHERE  (eid like '''+@p_eid+'%'+''' ) AND (' + @p_filtro + ') ORDER BY ' + @p_orden)
END
