
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_cnt_contratoDetalleVisita]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_cnt_contratoDetalleVisita]
GO
CREATE PROCEDURE [reg_cnt_contratoDetalleVisita]
	@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],
		[contratoDetalleVisita] AS [contratoDetalleVisita],
		[contratoDetalleVisita_codigo] AS [contratoDetalleVisita_codigo],
		[frecuencia] AS [frecuencia],
		[cadaN] AS [cadaN],
		[dia] AS [dia],
		[estrategia] AS [estrategia],
		[porTrabajo] AS [porTrabajo],
		[incluirMenores] AS [incluirMenores],
		[aproximarA] AS [aproximarA],
		[fecha_ff] AS [fecha_ff],
		[id_contrato] AS [id_contrato],
		[diaHabil] AS [diaHabil]
	FROM [cnt_contratoDetalleVisita]
	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_contratoDetalleVisita]')) DROP VIEW [dbo].[view_cnt_contratoDetalleVisita]
GO
CREATE  VIEW [view_cnt_contratoDetalleVisita] AS
SELECT 	[cnt_contratoDetalleVisita].[id] AS [id],
		[cnt_contratoDetalleVisita].[uid] AS [uid],
		[cnt_contratoDetalleVisita].[eid] AS [eid],
		[cnt_contratoDetalleVisita].[id_usuario_modifico] AS [id_usuario_modifico],
		[cnt_contratoDetalleVisita].[id_usuario_creo] AS [id_usuario_creo],
		[cnt_contratoDetalleVisita].[fechaModificacion] AS [fechaModificacion],
		[cnt_contratoDetalleVisita].[fechaCreacion] AS [fechaCreacion],
		[cnt_contratoDetalleVisita].[active] AS [active],
		[cnt_contratoDetalleVisita].[contratoDetalleVisita] AS [contratoDetalleVisita],
		[cnt_contratoDetalleVisita].[contratoDetalleVisita_codigo] AS [contratoDetalleVisita_codigo],
		[cnt_contratoDetalleVisita].[frecuencia] AS [frecuencia],
		[cnt_contratoDetalleVisita].[cadaN] AS [cadaN],
		[cnt_contratoDetalleVisita].[dia] AS [dia],
		[cnt_contratoDetalleVisita].[estrategia] AS [estrategia],
		[cnt_contratoDetalleVisita].[porTrabajo] AS [porTrabajo],
		[cnt_contratoDetalleVisita].[incluirMenores] AS [incluirMenores],
		[cnt_contratoDetalleVisita].[aproximarA] AS [aproximarA],
		[cnt_contratoDetalleVisita].[fecha_ff] AS [fecha_ff],
		[cnt_contratoDetalleVisita].[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].[id_estadoTipoDocumento_inicial] as [cnt_contrato_id_estadoTipoDocumento_inicial],
[cnt_contrato].[id_subtipoDocumento_solicitud] as [cnt_contrato_id_subtipoDocumento_solicitud],
		[cnt_contratoDetalleVisita].[diaHabil] AS [diaHabil],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [cnt_contratoDetalleVisita]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cnt_contratoDetalleVisita].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cnt_contratoDetalleVisita].[id_usuario_creo]
	INNER JOIN [cnt_contrato] ON [cnt_contrato].id=[cnt_contratoDetalleVisita].[id_contrato]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [cnt_contratoDetalleVisita].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1
WHERE [cnt_contratoDetalleVisita].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_contratoDetalleVisitasXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitasXusuario_modifico]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitasXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contratoDetalleVisita]
	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_contratoDetalleVisitasXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitasXusuario_creo]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitasXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contratoDetalleVisita]
	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_contratoDetalleVisitasXcontrato]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitasXcontrato]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitasXcontrato]
	@p_id_contrato INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contratoDetalleVisita]
	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_contratoDetalleVisitas]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitas]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitas]
	
	@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_contratoDetalleVisita]
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_contratoDetalleVisitas]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_cnt_contratoDetalleVisitas]
GO
CREATE PROCEDURE [lis_cnt_contratoDetalleVisitas]
	AS
BEGIN
	SELECT id AS id,
[contratoDetalleVisita] AS [cnt_contratoDetalleVisita]
	FROM [cnt_contratoDetalleVisita]
	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_contratoDetalleVisita]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_cnt_contratoDetalleVisita]
GO
CREATE PROCEDURE [upd_cnt_contratoDetalleVisita]
	@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_contratoDetalleVisita varchar(300) = null,
		@p_contratoDetalleVisita_codigo varchar(100) = null,
		@p_frecuencia int = null,
		@p_cadaN float = null,
		@p_dia int = null,
		@p_estrategia int = null,
		@p_porTrabajo bit = null,
		@p_incluirMenores bit = null,
		@p_aproximarA int = null,
		@p_fecha_ff smalldatetime = null,
		@p_id_contrato int = null,
		@p_diaHabil int = null
AS
BEGIN
		UPDATE [cnt_contratoDetalleVisita]
		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(),
			[contratoDetalleVisita] = isnull(@p_contratoDetalleVisita,[contratoDetalleVisita]),
			[contratoDetalleVisita_codigo] = isnull(@p_contratoDetalleVisita_codigo,[contratoDetalleVisita_codigo]),
			[frecuencia] = isnull(@p_frecuencia,[frecuencia]),
			[cadaN] = isnull(@p_cadaN,[cadaN]),
			[dia] = isnull(@p_dia,[dia]),
			[estrategia] = isnull(@p_estrategia,[estrategia]),
			[porTrabajo] = isnull(@p_porTrabajo,[porTrabajo]),
			[incluirMenores] = isnull(@p_incluirMenores,[incluirMenores]),
			[aproximarA] = isnull(@p_aproximarA,[aproximarA]),
			[fecha_ff] = isnull(@p_fecha_ff,[fecha_ff]),
			[id_contrato] = isnull(@p_id_contrato,[id_contrato]),
			[diaHabil] = isnull(@p_diaHabil,[diaHabil])
		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_contratoDetalleVisita]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_cnt_contratoDetalleVisita]
GO
CREATE PROCEDURE [ins_cnt_contratoDetalleVisita]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_contratoDetalleVisita varchar(300),
		@p_contratoDetalleVisita_codigo varchar(100),
		@p_frecuencia int,
		@p_cadaN float,
		@p_dia int,
		@p_estrategia int,
		@p_porTrabajo bit,
		@p_incluirMenores bit,
		@p_aproximarA int,
		@p_fecha_ff smalldatetime,
		@p_id_contrato int,
		@p_diaHabil int
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [cnt_contratoDetalleVisita]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[contratoDetalleVisita],
			[contratoDetalleVisita_codigo],
			[frecuencia],
			[cadaN],
			[dia],
			[estrategia],
			[porTrabajo],
			[incluirMenores],
			[aproximarA],
			[fecha_ff],
			[id_contrato],
			[diaHabil])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_contratoDetalleVisita,
			@p_contratoDetalleVisita_codigo,
			@p_frecuencia,
			@p_cadaN,
			@p_dia,
			@p_estrategia,
			@p_porTrabajo,
			@p_incluirMenores,
			@p_aproximarA,
			@p_fecha_ff,
			@p_id_contrato,
			@p_diaHabil)
		SET @v_id = scope_identity()
UPDATE [cnt_contratoDetalleVisita] 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_contratoDetalleVisita]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_cnt_contratoDetalleVisita]
GO
CREATE PROCEDURE [act_cnt_contratoDetalleVisita]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [cnt_contratoDetalleVisita]
	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_contratoDetalleVisita_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_cnt_contratoDetalleVisita_m]
GO
CREATE PROCEDURE [reg_cnt_contratoDetalleVisita_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],
		[contratoDetalleVisita] AS [contratoDetalleVisita],
		[contratoDetalleVisita_codigo] AS [contratoDetalleVisita_codigo],
		[frecuencia] AS [frecuencia],
		[cadaN] AS [cadaN],
		[dia] AS [dia],
		[estrategia] AS [estrategia],
		[porTrabajo] AS [porTrabajo],
		[incluirMenores] AS [incluirMenores],
		[aproximarA] AS [aproximarA],
		[fecha_ff] AS [fecha_ff],
		[id_contrato] AS [id_contrato],
		[diaHabil] AS [diaHabil]
	FROM [cnt_contratoDetalleVisita]
	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_contratoDetalleVisitasXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitasXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitasXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contratoDetalleVisita]
	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_contratoDetalleVisitasXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitasXusuario_creo_m]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitasXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contratoDetalleVisita]
	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_contratoDetalleVisitasXcontrato_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitasXcontrato_m]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitasXcontrato_m]
	@p_id_contrato INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contratoDetalleVisita]
	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_contratoDetalleVisitas_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contratoDetalleVisitas_m]
GO
CREATE PROCEDURE [sel_cnt_contratoDetalleVisitas_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_contratoDetalleVisita]
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_contratoDetalleVisitas_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_cnt_contratoDetalleVisitas_m]
GO
CREATE PROCEDURE [lis_cnt_contratoDetalleVisitas_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[contratoDetalleVisita] AS [cnt_contratoDetalleVisita]
	FROM [cnt_contratoDetalleVisita]
	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_contratoDetalleVisita]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_cnt_contratoDetalleVisita]
GO
CREATE PROCEDURE [aud_cnt_contratoDetalleVisita]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [cnt_contratoDetalleVisita].id as id_tabla,
	[cnt_contratoDetalleVisita].id_usuario_modifico as id_usuario_modifico,
	[cnt_contratoDetalleVisita].id_usuario_creo as id_usuario_creo,
	[cnt_contratoDetalleVisita].fechaModificacion as fechaModificacion,
	[cnt_contratoDetalleVisita].fechaCreacion as fechaCreacion,
	[cnt_contratoDetalleVisita].active as active,
	[cnt_contratoDetalleVisita].[contratoDetalleVisita] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

	FROM [cnt_contratoDetalleVisita]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cnt_contratoDetalleVisita].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cnt_contratoDetalleVisita].[id_usuario_creo]
	where ' + @p_filtro)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
print 'cnt_contratoDetalleVisita'
-----------------------------------30/10/2019 13:20:36