

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_cnt_contrato_tipoServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_cnt_contrato_tipoServicio]
GO
CREATE PROCEDURE [reg_cnt_contrato_tipoServicio]
	@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],
		[contrato_tipoServicio] AS [contrato_tipoServicio],
		[id_contrato] AS [id_contrato],
		[id_tipoServicio] AS [id_tipoServicio],
		[id_listaPrecio] AS [id_listaPrecio]
	FROM [cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServicio]')) DROP VIEW [dbo].[view_cnt_contrato_tipoServicio]
GO
CREATE  VIEW [view_cnt_contrato_tipoServicio] AS
SELECT 	[cnt_contrato_tipoServicio].[id] AS [id],
		[cnt_contrato_tipoServicio].[uid] AS [uid],
		[cnt_contrato_tipoServicio].[eid] AS [eid],
		[cnt_contrato_tipoServicio].[id_usuario_modifico] AS [id_usuario_modifico],
		[cnt_contrato_tipoServicio].[id_usuario_creo] AS [id_usuario_creo],
		[cnt_contrato_tipoServicio].[fechaModificacion] AS [fechaModificacion],
		[cnt_contrato_tipoServicio].[fechaCreacion] AS [fechaCreacion],
		[cnt_contrato_tipoServicio].[active] AS [active],
		[cnt_contrato_tipoServicio].[contrato_tipoServicio] AS [contrato_tipoServicio],
		[cnt_contrato_tipoServicio].[id_contrato] AS [id_contrato],
[cnt_contrato].[contrato] as [cnt_contrato_contrato],
[cnt_contrato].[contrato_codigo] as [cnt_contrato_contrato_codigo],
[cnt_contrato].[numero] as [cnt_contrato_numero],
[cnt_contrato].[totalContrato] as [cnt_contrato_totalContrato],
[cnt_contrato].[presupuesto] as [cnt_contrato_presupuesto],
[cnt_contrato].[fechaInicio_ff] as [cnt_contrato_fechaInicio_ff],
[cnt_contrato].[fechaFin_ff] as [cnt_contrato_fechaFin_ff],
[cnt_contrato].[diasCumplimiento] as [cnt_contrato_diasCumplimiento],
[cnt_contrato].[condiciones] as [cnt_contrato_condiciones],
[cnt_contrato].[id_periodoContrato] as [cnt_contrato_id_periodoContrato],
[cnt_contrato].[id_tercero] as [cnt_contrato_id_tercero],
[cnt_contrato].[id_tipoServicio] as [cnt_contrato_id_tipoServicio],
[cnt_contrato].[id_tipoContrato] as [cnt_contrato_id_tipoContrato],
[cnt_contrato].[id_tercero_servicio] as [cnt_contrato_id_tercero_servicio],
[cnt_contrato].[id_subtipoDocumento] as [cnt_contrato_id_subtipoDocumento],
[cnt_contrato].[id_departamentoSolicitud] as [cnt_contrato_id_departamentoSolicitud],
[cnt_contrato].[id_usuario_coordinador] as [cnt_contrato_id_usuario_coordinador],
[cnt_contrato].[id_documento.alquiler] as [cnt_contrato_id_documento.alquiler],
		[cnt_contrato_tipoServicio].[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],
		[cnt_contrato_tipoServicio].[id_listaPrecio] AS [id_listaPrecio],
[cat_listaPrecio].[listaPrecio] as [cat_listaPrecio_listaPrecio],
[cat_listaPrecio].[listaPrecio_codigo] as [cat_listaPrecio_listaPrecio_codigo],
[cat_listaPrecio].[porcentajeDescuento] as [cat_listaPrecio_porcentajeDescuento],
[cat_listaPrecio].[esPrivado] as [cat_listaPrecio_esPrivado],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [cnt_contrato_tipoServicio]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cnt_contrato_tipoServicio].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cnt_contrato_tipoServicio].[id_usuario_creo]
	INNER JOIN [cnt_contrato] ON [cnt_contrato].id=[cnt_contrato_tipoServicio].[id_contrato]
	INNER JOIN [gen_tipoServicio] ON [gen_tipoServicio].id=[cnt_contrato_tipoServicio].[id_tipoServicio]
	INNER JOIN [cat_listaPrecio] ON [cat_listaPrecio].id=[cnt_contrato_tipoServicio].[id_listaPrecio]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [cnt_contrato_tipoServicio].eid = [empresaCodigo].[codigo] and empresaCodigo.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_cnt_contrato_tipoServiciosXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXusuario_modifico]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServiciosXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXusuario_creo]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServiciosXcontrato]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXcontrato]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXcontrato]
	@p_id_contrato INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_tipoServicio]
	WHERE ([id_contrato]= @p_id_contrato)
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_cnt_contrato_tipoServiciosXtipoServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXtipoServicio]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXtipoServicio]
	@p_id_tipoServicio INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServiciosXlistaPrecio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXlistaPrecio]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXlistaPrecio]
	@p_id_listaPrecio INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_tipoServicio]
	WHERE ([id_listaPrecio]= @p_id_listaPrecio)
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_cnt_contrato_tipoServicios]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServicios]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServicios]
	
	@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_cnt_contrato_tipoServicio]
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_cnt_contrato_tipoServicios]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_cnt_contrato_tipoServicios]
GO
CREATE PROCEDURE [lis_cnt_contrato_tipoServicios]
	AS
BEGIN
	SELECT id AS id,
[contrato_tipoServicio] AS [cnt_contrato_tipoServicio]
	FROM [cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_cnt_contrato_tipoServicio]
GO
CREATE PROCEDURE [upd_cnt_contrato_tipoServicio]
	@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_contrato_tipoServicio varchar(300) = null,
		@p_id_contrato int = null,
		@p_id_tipoServicio int = null,
		@p_id_listaPrecio int = null
AS
BEGIN
		UPDATE [cnt_contrato_tipoServicio]
		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(),
			[contrato_tipoServicio] = isnull(@p_contrato_tipoServicio,[contrato_tipoServicio]),
			[id_contrato] = isnull(@p_id_contrato,[id_contrato]),
			[id_tipoServicio] = isnull(@p_id_tipoServicio,[id_tipoServicio]),
			[id_listaPrecio] = isnull(@p_id_listaPrecio,[id_listaPrecio])
		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_cnt_contrato_tipoServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_cnt_contrato_tipoServicio]
GO
CREATE PROCEDURE [ins_cnt_contrato_tipoServicio]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_contrato_tipoServicio varchar(300),
		@p_id_contrato int,
		@p_id_tipoServicio int,
		@p_id_listaPrecio int
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [cnt_contrato_tipoServicio]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[contrato_tipoServicio],
			[id_contrato],
			[id_tipoServicio],
			[id_listaPrecio])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_contrato_tipoServicio,
			@p_id_contrato,
			@p_id_tipoServicio,
			@p_id_listaPrecio)
		SET @v_id = scope_identity()
UPDATE [cnt_contrato_tipoServicio] 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_cnt_contrato_tipoServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_cnt_contrato_tipoServicio]
GO
CREATE PROCEDURE [act_cnt_contrato_tipoServicio]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServicio_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_cnt_contrato_tipoServicio_m]
GO
CREATE PROCEDURE [reg_cnt_contrato_tipoServicio_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],
		[contrato_tipoServicio] AS [contrato_tipoServicio],
		[id_contrato] AS [id_contrato],
		[id_tipoServicio] AS [id_tipoServicio],
		[id_listaPrecio] AS [id_listaPrecio]
	FROM [cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServiciosXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServiciosXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXusuario_creo_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServiciosXcontrato_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXcontrato_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXcontrato_m]
	@p_id_contrato INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_tipoServicio]
	WHERE ([id_contrato]= @p_id_contrato)
	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_cnt_contrato_tipoServiciosXtipoServicio_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXtipoServicio_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXtipoServicio_m]
	@p_id_tipoServicio INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServiciosXlistaPrecio_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServiciosXlistaPrecio_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServiciosXlistaPrecio_m]
	@p_id_listaPrecio INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_tipoServicio]
	WHERE ([id_listaPrecio]= @p_id_listaPrecio)
	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_cnt_contrato_tipoServicios_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_tipoServicios_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_tipoServicios_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_cnt_contrato_tipoServicio]
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_cnt_contrato_tipoServicios_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_cnt_contrato_tipoServicios_m]
GO
CREATE PROCEDURE [lis_cnt_contrato_tipoServicios_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[contrato_tipoServicio] AS [cnt_contrato_tipoServicio]
	FROM [cnt_contrato_tipoServicio]
	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_cnt_contrato_tipoServicio]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_cnt_contrato_tipoServicio]
GO
CREATE PROCEDURE [aud_cnt_contrato_tipoServicio]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [cnt_contrato_tipoServicio].id as id_tabla,
	[cnt_contrato_tipoServicio].id_usuario_modifico as id_usuario_modifico,
	[cnt_contrato_tipoServicio].id_usuario_creo as id_usuario_creo,
	[cnt_contrato_tipoServicio].fechaModificacion as fechaModificacion,
	[cnt_contrato_tipoServicio].fechaCreacion as fechaCreacion,
	[cnt_contrato_tipoServicio].active as active,
	[cnt_contrato_tipoServicio].[contrato_tipoServicio] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

	FROM [cnt_contrato_tipoServicio]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cnt_contrato_tipoServicio].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cnt_contrato_tipoServicio].[id_usuario_creo]
	where ' + @p_filtro)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
print 'cnt_contrato_tipoServicio'
-----------------------------------07/04/2016 14:28:43