


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_sucursal]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_cnt_contrato_sucursal]
GO
CREATE PROCEDURE [reg_cnt_contrato_sucursal]
	@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_sucursal] AS [contrato_sucursal],
		[precioVisita] AS [precioVisita],
		[precioServicio] AS [precioServicio],
		[id_contrato] AS [id_contrato],
		[id_sucursal] AS [id_sucursal],
		[presupuesto] AS [presupuesto]
	FROM [cnt_contrato_sucursal]
	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_sucursal]')) DROP VIEW [dbo].[view_cnt_contrato_sucursal]
GO
CREATE  VIEW [view_cnt_contrato_sucursal] AS
SELECT 	[cnt_contrato_sucursal].[id] AS [id],
		[cnt_contrato_sucursal].[uid] AS [uid],
		[cnt_contrato_sucursal].[eid] AS [eid],
		[cnt_contrato_sucursal].[id_usuario_modifico] AS [id_usuario_modifico],
		[cnt_contrato_sucursal].[id_usuario_creo] AS [id_usuario_creo],
		[cnt_contrato_sucursal].[fechaModificacion] AS [fechaModificacion],
		[cnt_contrato_sucursal].[fechaCreacion] AS [fechaCreacion],
		[cnt_contrato_sucursal].[active] AS [active],
		[cnt_contrato_sucursal].[contrato_sucursal] AS [contrato_sucursal],
		[cnt_contrato_sucursal].[precioVisita] AS [precioVisita],
		[cnt_contrato_sucursal].[precioServicio] AS [precioServicio],
		[cnt_contrato_sucursal].[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_sucursal].[id_sucursal] AS [id_sucursal],
[ter_sucursal].[sucursal] as [ter_sucursal_sucursal],
[ter_sucursal].[sucursal_codigo] as [ter_sucursal_sucursal_codigo],
[ter_sucursal].[contacto] as [ter_sucursal_contacto],
[ter_sucursal].[telefono] as [ter_sucursal_telefono],
[ter_sucursal].[Fax] as [ter_sucursal_Fax],
[ter_sucursal].[Email] as [ter_sucursal_Email],
[ter_sucursal].[Direccion] as [ter_sucursal_Direccion],
[ter_sucursal].[paraVenta] as [ter_sucursal_paraVenta],
[ter_sucursal].[paraSoporte] as [ter_sucursal_paraSoporte],
[ter_sucursal].[paraAlquiler] as [ter_sucursal_paraAlquiler],
[ter_sucursal].[id_tercero] as [ter_sucursal_id_tercero],
[ter_sucursal].[id_zona] as [ter_sucursal_id_zona],
[ter_sucursal].[id_usuario_asesor] as [ter_sucursal_id_usuario_asesor],
[ter_sucursal].[id_usuario_tecnico] as [ter_sucursal_id_usuario_tecnico],
[ter_sucursal].[id_sucursal] as [ter_sucursal_id_sucursal],
[ter_sucursal].[id_listaPrecio] as [ter_sucursal_id_listaPrecio],
[ter_sucursal].[id_estadoTercero] as [ter_sucursal_id_estadoTercero],
		[cnt_contrato_sucursal].[presupuesto] AS [presupuesto],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [cnt_contrato_sucursal]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cnt_contrato_sucursal].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cnt_contrato_sucursal].[id_usuario_creo]
	INNER JOIN [cnt_contrato] ON [cnt_contrato].id=[cnt_contrato_sucursal].[id_contrato]
	INNER JOIN [ter_sucursal] ON [ter_sucursal].id=[cnt_contrato_sucursal].[id_sucursal]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [cnt_contrato_sucursal].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_sucursalesXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXusuario_modifico]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_sucursal]
	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_sucursalesXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXusuario_creo]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_sucursal]
	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_sucursalesXcontrato]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXcontrato]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXcontrato]
	@p_id_contrato INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_sucursal]
	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_sucursalesXsucursal]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXsucursal]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXsucursal]
	@p_id_sucursal INT
AS
BEGIN
	SELECT * 
	FROM [view_cnt_contrato_sucursal]
	WHERE ([id_sucursal]= @p_id_sucursal)
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_sucursales]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursales]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursales]
	
	@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_sucursal]
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_sucursales]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_cnt_contrato_sucursales]
GO
CREATE PROCEDURE [lis_cnt_contrato_sucursales]
	AS
BEGIN
	SELECT id AS id,
[contrato_sucursal] AS [cnt_contrato_sucursal]
	FROM [cnt_contrato_sucursal]
	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_sucursal]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_cnt_contrato_sucursal]
GO
CREATE PROCEDURE [upd_cnt_contrato_sucursal]
	@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_sucursal varchar(300) = null,
		@p_precioVisita money = null,
		@p_precioServicio money = null,
		@p_id_contrato int = null,
		@p_id_sucursal int = null,
		@p_presupuesto money = null
AS
BEGIN
		UPDATE [cnt_contrato_sucursal]
		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_sucursal] = isnull(@p_contrato_sucursal,[contrato_sucursal]),
			[precioVisita] = isnull(@p_precioVisita,[precioVisita]),
			[precioServicio] = isnull(@p_precioServicio,[precioServicio]),
			[id_contrato] = isnull(@p_id_contrato,[id_contrato]),
			[id_sucursal] = isnull(@p_id_sucursal,[id_sucursal]),
			[presupuesto] = isnull(@p_presupuesto,[presupuesto])
		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_sucursal]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_cnt_contrato_sucursal]
GO
CREATE PROCEDURE [ins_cnt_contrato_sucursal]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_contrato_sucursal varchar(300),
		@p_precioVisita money,
		@p_precioServicio money,
		@p_id_contrato int,
		@p_id_sucursal int,
		@p_presupuesto money
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [cnt_contrato_sucursal]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[contrato_sucursal],
			[precioVisita],
			[precioServicio],
			[id_contrato],
			[id_sucursal],
			[presupuesto])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_contrato_sucursal,
			@p_precioVisita,
			@p_precioServicio,
			@p_id_contrato,
			@p_id_sucursal,
			@p_presupuesto)
		SET @v_id = scope_identity()
UPDATE [cnt_contrato_sucursal] 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_sucursal]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_cnt_contrato_sucursal]
GO
CREATE PROCEDURE [act_cnt_contrato_sucursal]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [cnt_contrato_sucursal]
	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_sucursal_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_cnt_contrato_sucursal_m]
GO
CREATE PROCEDURE [reg_cnt_contrato_sucursal_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_sucursal] AS [contrato_sucursal],
		[precioVisita] AS [precioVisita],
		[precioServicio] AS [precioServicio],
		[id_contrato] AS [id_contrato],
		[id_sucursal] AS [id_sucursal],
		[presupuesto] AS [presupuesto]
	FROM [cnt_contrato_sucursal]
	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_sucursalesXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_sucursal]
	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_sucursalesXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXusuario_creo_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_sucursal]
	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_sucursalesXcontrato_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXcontrato_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXcontrato_m]
	@p_id_contrato INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_sucursal]
	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_sucursalesXsucursal_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursalesXsucursal_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursalesXsucursal_m]
	@p_id_sucursal INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_cnt_contrato_sucursal]
	WHERE ([id_sucursal]= @p_id_sucursal)
	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_sucursales_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_cnt_contrato_sucursales_m]
GO
CREATE PROCEDURE [sel_cnt_contrato_sucursales_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_sucursal]
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_sucursales_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_cnt_contrato_sucursales_m]
GO
CREATE PROCEDURE [lis_cnt_contrato_sucursales_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[contrato_sucursal] AS [cnt_contrato_sucursal]
	FROM [cnt_contrato_sucursal]
	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_sucursal]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_cnt_contrato_sucursal]
GO
CREATE PROCEDURE [aud_cnt_contrato_sucursal]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [cnt_contrato_sucursal].id as id_tabla,
	[cnt_contrato_sucursal].id_usuario_modifico as id_usuario_modifico,
	[cnt_contrato_sucursal].id_usuario_creo as id_usuario_creo,
	[cnt_contrato_sucursal].fechaModificacion as fechaModificacion,
	[cnt_contrato_sucursal].fechaCreacion as fechaCreacion,
	[cnt_contrato_sucursal].active as active,
	[cnt_contrato_sucursal].[contrato_sucursal] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

	FROM [cnt_contrato_sucursal]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[cnt_contrato_sucursal].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[cnt_contrato_sucursal].[id_usuario_creo]
	where ' + @p_filtro)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
print 'cnt_contrato_sucursal'
-----------------------------------30/09/2013 02:37:24 p.m.