
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_gen_configuracionServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_gen_configuracionServicio]
GO
CREATE PROCEDURE [reg_gen_configuracionServicio]
	@p_id INT
AS
BEGIN
	SELECT 	[id] AS [id],
		[uid] AS [uid],
		[eid] AS [eid],
		[id_usuario_modifico] AS [id_usuario_modifico],
		[id_usuario_creo] AS [id_usuario_creo],
		[fechaModificacion] AS [fechaModificacion],
		[fechaCreacion] AS [fechaCreacion],
		[active] AS [active],
		[configuracionServicio] AS [configuracionServicio],
		[configuracionServicio_codigo] AS [configuracionServicio_codigo],
		[id_tercero] AS [id_tercero],
		[id_tipoServicio] AS [id_tipoServicio],
		[id_catalogo] AS [id_catalogo]
	FROM [gen_configuracionServicio]
	WHERE	(id = @p_id)

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.views WHERE object_id = OBJECT_ID(N'[dbo].[view_gen_configuracionServicio]')) DROP VIEW [dbo].[view_gen_configuracionServicio]
GO
CREATE  VIEW [view_gen_configuracionServicio] AS
SELECT 	[gen_configuracionServicio].[id] AS [id],
		[gen_configuracionServicio].[uid] AS [uid],
		[gen_configuracionServicio].[eid] AS [eid],
		[gen_configuracionServicio].[id_usuario_modifico] AS [id_usuario_modifico],
		[gen_configuracionServicio].[id_usuario_creo] AS [id_usuario_creo],
		[gen_configuracionServicio].[fechaModificacion] AS [fechaModificacion],
		[gen_configuracionServicio].[fechaCreacion] AS [fechaCreacion],
		[gen_configuracionServicio].[active] AS [active],
		[gen_configuracionServicio].[configuracionServicio] AS [configuracionServicio],
		[gen_configuracionServicio].[configuracionServicio_codigo] AS [configuracionServicio_codigo],
		[gen_configuracionServicio].[id_tercero] AS [id_tercero],
[ter_tercero].[tercero] as [ter_tercero_tercero],
[ter_tercero].[tercero_codigo] as [ter_tercero_tercero_codigo],
[ter_tercero].[tercero_nit] as [ter_tercero_tercero_nit],
[ter_tercero].[direccion] as [ter_tercero_direccion],
[ter_tercero].[contacto] as [ter_tercero_contacto],
[ter_tercero].[telefono] as [ter_tercero_telefono],
[ter_tercero].[fax] as [ter_tercero_fax],
[ter_tercero].[email] as [ter_tercero_email],
[ter_tercero].[website] as [ter_tercero_website],
[ter_tercero].[representante] as [ter_tercero_representante],
[ter_tercero].[notas] as [ter_tercero_notas],
[ter_tercero].[tercero_nombreCorto] as [ter_tercero_tercero_nombreCorto],
[ter_tercero].[esCliente] as [ter_tercero_esCliente],
[ter_tercero].[esProveedor] as [ter_tercero_esProveedor],
[ter_tercero].[esTransportador] as [ter_tercero_esTransportador],
[ter_tercero].[esFabricante] as [ter_tercero_esFabricante],
[ter_tercero].[esEmpresaPropia] as [ter_tercero_esEmpresaPropia],
[ter_tercero].[clasificacion] as [ter_tercero_clasificacion],
[ter_tercero].[id_zona] as [ter_tercero_id_zona],
[ter_tercero].[id_estadoTercero] as [ter_tercero_id_estadoTercero],
[ter_tercero].[id_naturalezaTercero] as [ter_tercero_id_naturalezaTercero],
[ter_tercero].[esProspecto] as [ter_tercero_esProspecto],
		[gen_configuracionServicio].[id_tipoServicio] AS [id_tipoServicio],
[gen_tipoServicio].[tipoServicio] as [gen_tipoServicio_tipoServicio],
[gen_tipoServicio].[tipoServicio_codigo] as [gen_tipoServicio_tipoServicio_codigo],
[gen_tipoServicio].[tieneGarantia] as [gen_tipoServicio_tieneGarantia],
[gen_tipoServicio].[diasGarantia] as [gen_tipoServicio_diasGarantia],
		[gen_configuracionServicio].[id_catalogo] AS [id_catalogo],
[cat_catalogo].[catalogo] as [cat_catalogo_catalogo],
[cat_catalogo].[catalogo_codigo] as [cat_catalogo_catalogo_codigo],
[cat_catalogo].[codigoInventario] as [cat_catalogo_codigoInventario],
[cat_catalogo].[precioVenta] as [cat_catalogo_precioVenta],
[cat_catalogo].[tiempoConsecucion] as [cat_catalogo_tiempoConsecucion],
[cat_catalogo].[esNacional] as [cat_catalogo_esNacional],
[cat_catalogo].[id_familia] as [cat_catalogo_id_familia],
[cat_catalogo].[id_subtipoCatalogo] as [cat_catalogo_id_subtipoCatalogo],
[cat_catalogo].[id_unidad] as [cat_catalogo_id_unidad],
[cat_catalogo].[id_impuesto] as [cat_catalogo_id_impuesto],
[cat_catalogo].[descripcion] as [cat_catalogo_descripcion],
[cat_catalogo].[bloquearCostear] as [cat_catalogo_bloquearCostear],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [gen_configuracionServicio]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[gen_configuracionServicio].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[gen_configuracionServicio].[id_usuario_creo]
	INNER JOIN [ter_tercero] ON [ter_tercero].id=[gen_configuracionServicio].[id_tercero]
	INNER JOIN [gen_tipoServicio] ON [gen_tipoServicio].id=[gen_configuracionServicio].[id_tipoServicio]
	INNER JOIN [cat_catalogo] ON [cat_catalogo].id=[gen_configuracionServicio].[id_catalogo]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [gen_configuracionServicio].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1
WHERE [gen_configuracionServicio].active=1
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXusuario_modifico]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_gen_configuracionServicio]
	WHERE ([id_usuario_modifico]= @p_id_usuario_modifico)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXusuario_creo]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_gen_configuracionServicio]
	WHERE ([id_usuario_creo]= @p_id_usuario_creo)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXtercero]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXtercero]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXtercero]
	@p_id_tercero INT
AS
BEGIN
	SELECT * 
	FROM [view_gen_configuracionServicio]
	WHERE ([id_tercero]= @p_id_tercero)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXtipoServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXtipoServicio]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXtipoServicio]
	@p_id_tipoServicio INT
AS
BEGIN
	SELECT * 
	FROM [view_gen_configuracionServicio]
	WHERE ([id_tipoServicio]= @p_id_tipoServicio)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXcatalogo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXcatalogo]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXcatalogo]
	@p_id_catalogo INT
AS
BEGIN
	SELECT * 
	FROM [view_gen_configuracionServicio]
	WHERE ([id_catalogo]= @p_id_catalogo)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServicios]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServicios]
GO
CREATE PROCEDURE [sel_gen_configuracionServicios]
	
	@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_gen_configuracionServicio]
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 OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[lis_gen_configuracionServicios]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_gen_configuracionServicios]
GO
CREATE PROCEDURE [lis_gen_configuracionServicios]
	AS
BEGIN
	SELECT id AS id,
[configuracionServicio] AS [gen_configuracionServicio]
	FROM [gen_configuracionServicio]
	WHERE active = 1
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[upd_gen_configuracionServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_gen_configuracionServicio]
GO
CREATE PROCEDURE [upd_gen_configuracionServicio]
	@p_id int = null,
		@p_uid varchar(500) = null,
		@p_eid varchar(50) = null,
		@p_id_usuario_modifico int = null,
		@p_id_usuario_creo int = null,
		@p_fechaCreacion smalldatetime = null,
		@p_configuracionServicio varchar(300) = null,
		@p_configuracionServicio_codigo varchar(100) = null,
		@p_id_tercero int = null,
		@p_id_tipoServicio int = null,
		@p_id_catalogo int = null
AS
BEGIN
		UPDATE [gen_configuracionServicio]
		SET	[uid] = isnull(@p_uid,[uid]),
			[eid] = isnull(@p_eid,[eid]),
			[id_usuario_modifico] = isnull(@p_id_usuario_modifico,[id_usuario_modifico]),
			[id_usuario_creo] = isnull(@p_id_usuario_creo,[id_usuario_creo]),
			[fechaModificacion] = GETDATE(),
			[configuracionServicio] = isnull(@p_configuracionServicio,[configuracionServicio]),
			[configuracionServicio_codigo] = isnull(@p_configuracionServicio_codigo,[configuracionServicio_codigo]),
			[id_tercero] = isnull(@p_id_tercero,[id_tercero]),
			[id_tipoServicio] = isnull(@p_id_tipoServicio,[id_tipoServicio]),
			[id_catalogo] = isnull(@p_id_catalogo,[id_catalogo])
		WHERE (id = @p_id)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ins_gen_configuracionServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_gen_configuracionServicio]
GO
CREATE PROCEDURE [ins_gen_configuracionServicio]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_configuracionServicio varchar(300),
		@p_configuracionServicio_codigo varchar(100),
		@p_id_tercero int,
		@p_id_tipoServicio int,
		@p_id_catalogo int
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [gen_configuracionServicio]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[configuracionServicio],
			[configuracionServicio_codigo],
			[id_tercero],
			[id_tipoServicio],
			[id_catalogo])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_configuracionServicio,
			@p_configuracionServicio_codigo,
			@p_id_tercero,
			@p_id_tipoServicio,
			@p_id_catalogo)
		SET @v_id = scope_identity()
UPDATE [gen_configuracionServicio] set [uid] = [uid] + '_' + convert(varchar(20),@v_id) where [id]=@v_id
SELECT @v_id as id
RETURN @v_id
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[act_gen_configuracionServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_gen_configuracionServicio]
GO
CREATE PROCEDURE [act_gen_configuracionServicio]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [gen_configuracionServicio]
	SET active=@p_active,
	[id_usuario_modifico] = isnull(@p_id_usuario_modifico,[id_usuario_modifico]),
	[fechaModificacion] = GETDATE()
	WHERE	(id = @p_id)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_gen_configuracionServicio_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_gen_configuracionServicio_m]
GO
CREATE PROCEDURE [reg_gen_configuracionServicio_m]
	@p_id INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT 	[id] AS [id],
		[uid] AS [uid],
		[eid] AS [eid],
		[id_usuario_modifico] AS [id_usuario_modifico],
		[id_usuario_creo] AS [id_usuario_creo],
		[fechaModificacion] AS [fechaModificacion],
		[fechaCreacion] AS [fechaCreacion],
		[active] AS [active],
		[configuracionServicio] AS [configuracionServicio],
		[configuracionServicio_codigo] AS [configuracionServicio_codigo],
		[id_tercero] AS [id_tercero],
		[id_tipoServicio] AS [id_tipoServicio],
		[id_catalogo] AS [id_catalogo]
	FROM [gen_configuracionServicio]
	WHERE	(id = @p_id)
	AND	(eid LIKE @p_eid+'%')

END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_gen_configuracionServicio]
	WHERE ([id_usuario_modifico]= @p_id_usuario_modifico)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXusuario_creo_m]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_gen_configuracionServicio]
	WHERE ([id_usuario_creo]= @p_id_usuario_creo)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXtercero_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXtercero_m]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXtercero_m]
	@p_id_tercero INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_gen_configuracionServicio]
	WHERE ([id_tercero]= @p_id_tercero)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXtipoServicio_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXtipoServicio_m]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXtipoServicio_m]
	@p_id_tipoServicio INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_gen_configuracionServicio]
	WHERE ([id_tipoServicio]= @p_id_tipoServicio)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServiciosXcatalogo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServiciosXcatalogo_m]
GO
CREATE PROCEDURE [sel_gen_configuracionServiciosXcatalogo_m]
	@p_id_catalogo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_gen_configuracionServicio]
	WHERE ([id_catalogo]= @p_id_catalogo)
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sel_gen_configuracionServicios_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_gen_configuracionServicios_m]
GO
CREATE PROCEDURE [sel_gen_configuracionServicios_m]
	@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_gen_configuracionServicio]
WHERE  (eid like '''+@p_eid+'%'+''' ) AND (' + @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 OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[lis_gen_configuracionServicios_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_gen_configuracionServicios_m]
GO
CREATE PROCEDURE [lis_gen_configuracionServicios_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[configuracionServicio] AS [gen_configuracionServicio]
	FROM [gen_configuracionServicio]
	WHERE active = 1
	AND	(eid LIKE @p_eid+'%')
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[aud_gen_configuracionServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_gen_configuracionServicio]
GO
CREATE PROCEDURE [aud_gen_configuracionServicio]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [gen_configuracionServicio].id as id_tabla,
	[gen_configuracionServicio].id_usuario_modifico as id_usuario_modifico,
	[gen_configuracionServicio].id_usuario_creo as id_usuario_creo,
	[gen_configuracionServicio].fechaModificacion as fechaModificacion,
	[gen_configuracionServicio].fechaCreacion as fechaCreacion,
	[gen_configuracionServicio].active as active,
	[gen_configuracionServicio].[configuracionServicio] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

	FROM [gen_configuracionServicio]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[gen_configuracionServicio].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[gen_configuracionServicio].[id_usuario_creo]
	where ' + @p_filtro)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
print 'gen_configuracionServicio'
-----------------------------------24/06/2020 15:45:24