
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_pro_SesionActividad]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_pro_SesionActividad]
GO
CREATE PROCEDURE [reg_pro_SesionActividad]
	@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],
		[SesionActividad] AS [SesionActividad],
		[SesionActividad_codigo] AS [SesionActividad_codigo],
		[id_actividad] AS [id_actividad],
		[id_ejecutores] AS [id_ejecutores],
		[id_GrupoSesion] AS [id_GrupoSesion],
		[duracion] AS [duracion],
		[descripcion] AS [descripcion],
		[fecha_inicio] AS [fecha_inicio]
	FROM [pro_SesionActividad]
	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_pro_SesionActividad]')) DROP VIEW [dbo].[view_pro_SesionActividad]
GO
CREATE  VIEW [view_pro_SesionActividad] AS
SELECT 	[pro_SesionActividad].[id] AS [id],
		[pro_SesionActividad].[uid] AS [uid],
		[pro_SesionActividad].[eid] AS [eid],
		[pro_SesionActividad].[id_usuario_modifico] AS [id_usuario_modifico],
		[pro_SesionActividad].[id_usuario_creo] AS [id_usuario_creo],
		[pro_SesionActividad].[fechaModificacion] AS [fechaModificacion],
		[pro_SesionActividad].[fechaCreacion] AS [fechaCreacion],
		[pro_SesionActividad].[active] AS [active],
		[pro_SesionActividad].[SesionActividad] AS [SesionActividad],
		[pro_SesionActividad].[SesionActividad_codigo] AS [SesionActividad_codigo],
		[pro_SesionActividad].[id_actividad] AS [id_actividad],
[pro_actividad].[actividad] as [pro_actividad_actividad],
[pro_actividad].[actividad_codigo] as [pro_actividad_actividad_codigo],
[pro_actividad].[descripcionDetallada] as [pro_actividad_descripcionDetallada],
[pro_actividad].[fechainicioPlaneada] as [pro_actividad_fechainicioPlaneada],
[pro_actividad].[fechainicioProyectada] as [pro_actividad_fechainicioProyectada],
[pro_actividad].[fechaInicioReal] as [pro_actividad_fechaInicioReal],
[pro_actividad].[duracion] as [pro_actividad_duracion],
[pro_actividad].[fechaTerminacionPlaneada] as [pro_actividad_fechaTerminacionPlaneada],
[pro_actividad].[fechaTerminacionProyectada] as [pro_actividad_fechaTerminacionProyectada],
[pro_actividad].[fechaTerminacionReal] as [pro_actividad_fechaTerminacionReal],
		[pro_SesionActividad].[id_ejecutores] AS [id_ejecutores],
[pro_ejecutores].[ejecutores] as [pro_ejecutores_ejecutores],
[pro_ejecutores].[ejecutores_codigo] as [pro_ejecutores_ejecutores_codigo],
[pro_ejecutores].[costo] as [pro_ejecutores_costo],
[pro_ejecutores].[unidadTiempo] as [pro_ejecutores_unidadTiempo],
[pro_ejecutores].[id_horarioEjecutores] as [pro_ejecutores_id_horarioEjecutores],
[pro_ejecutores].[id_usuario] as [pro_ejecutores_id_usuario],
		[pro_SesionActividad].[id_GrupoSesion] AS [id_GrupoSesion],
[pro_GrupoSesion].[GrupoSesion] as [pro_GrupoSesion_GrupoSesion],
[pro_GrupoSesion].[GrupoSesion_codigo] as [pro_GrupoSesion_GrupoSesion_codigo],
		[pro_SesionActividad].[duracion] AS [duracion],
		[pro_SesionActividad].[descripcion] AS [descripcion],
		[pro_SesionActividad].[fecha_inicio] AS [fecha_inicio],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [pro_SesionActividad]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[pro_SesionActividad].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[pro_SesionActividad].[id_usuario_creo]
	INNER JOIN [pro_actividad] ON [pro_actividad].id=[pro_SesionActividad].[id_actividad]
	INNER JOIN [pro_ejecutores] ON [pro_ejecutores].id=[pro_SesionActividad].[id_ejecutores]
	INNER JOIN [pro_GrupoSesion] ON [pro_GrupoSesion].id=[pro_SesionActividad].[id_GrupoSesion]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [pro_SesionActividad].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1
WHERE [pro_SesionActividad].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_pro_SesionActividadesXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXusuario_modifico]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_pro_SesionActividad]
	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_pro_SesionActividadesXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXusuario_creo]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_pro_SesionActividad]
	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_pro_SesionActividadesXactividad]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXactividad]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXactividad]
	@p_id_actividad INT
AS
BEGIN
	SELECT * 
	FROM [view_pro_SesionActividad]
	WHERE ([id_actividad]= @p_id_actividad)
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_pro_SesionActividadesXejecutores]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXejecutores]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXejecutores]
	@p_id_ejecutores INT
AS
BEGIN
	SELECT * 
	FROM [view_pro_SesionActividad]
	WHERE ([id_ejecutores]= @p_id_ejecutores)
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_pro_SesionActividadesXGrupoSesion]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXGrupoSesion]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXGrupoSesion]
	@p_id_GrupoSesion INT
AS
BEGIN
	SELECT * 
	FROM [view_pro_SesionActividad]
	WHERE ([id_GrupoSesion]= @p_id_GrupoSesion)
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_pro_SesionActividades]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividades]
GO
CREATE PROCEDURE [sel_pro_SesionActividades]
	
	@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_pro_SesionActividad]
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_pro_SesionActividades]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_pro_SesionActividades]
GO
CREATE PROCEDURE [lis_pro_SesionActividades]
	AS
BEGIN
	SELECT id AS id,
[SesionActividad] AS [pro_SesionActividad]
	FROM [pro_SesionActividad]
	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_pro_SesionActividad]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_pro_SesionActividad]
GO
CREATE PROCEDURE [upd_pro_SesionActividad]
	@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_SesionActividad varchar(300) = null,
		@p_SesionActividad_codigo varchar(100) = null,
		@p_id_actividad int = null,
		@p_id_ejecutores int = null,
		@p_id_GrupoSesion int = null,
		@p_duracion float = null,
		@p_descripcion varchar(3000) = null,
		@p_fecha_inicio smalldatetime = null
AS
BEGIN
		UPDATE [pro_SesionActividad]
		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(),
			[SesionActividad] = isnull(@p_SesionActividad,[SesionActividad]),
			[SesionActividad_codigo] = isnull(@p_SesionActividad_codigo,[SesionActividad_codigo]),
			[id_actividad] = isnull(@p_id_actividad,[id_actividad]),
			[id_ejecutores] = isnull(@p_id_ejecutores,[id_ejecutores]),
			[id_GrupoSesion] = isnull(@p_id_GrupoSesion,[id_GrupoSesion]),
			[duracion] = isnull(@p_duracion,[duracion]),
			[descripcion] = isnull(@p_descripcion,[descripcion]),
			[fecha_inicio] = isnull(@p_fecha_inicio,[fecha_inicio])
		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_pro_SesionActividad]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_pro_SesionActividad]
GO
CREATE PROCEDURE [ins_pro_SesionActividad]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_SesionActividad varchar(300),
		@p_SesionActividad_codigo varchar(100),
		@p_id_actividad int,
		@p_id_ejecutores int,
		@p_id_GrupoSesion int,
		@p_duracion float,
		@p_descripcion varchar(3000),
		@p_fecha_inicio smalldatetime
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [pro_SesionActividad]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[SesionActividad],
			[SesionActividad_codigo],
			[id_actividad],
			[id_ejecutores],
			[id_GrupoSesion],
			[duracion],
			[descripcion],
			[fecha_inicio])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_SesionActividad,
			@p_SesionActividad_codigo,
			@p_id_actividad,
			@p_id_ejecutores,
			@p_id_GrupoSesion,
			@p_duracion,
			@p_descripcion,
			@p_fecha_inicio)
		SET @v_id = scope_identity()
UPDATE [pro_SesionActividad] 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_pro_SesionActividad]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_pro_SesionActividad]
GO
CREATE PROCEDURE [act_pro_SesionActividad]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [pro_SesionActividad]
	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_pro_SesionActividad_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_pro_SesionActividad_m]
GO
CREATE PROCEDURE [reg_pro_SesionActividad_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],
		[SesionActividad] AS [SesionActividad],
		[SesionActividad_codigo] AS [SesionActividad_codigo],
		[id_actividad] AS [id_actividad],
		[id_ejecutores] AS [id_ejecutores],
		[id_GrupoSesion] AS [id_GrupoSesion],
		[duracion] AS [duracion],
		[descripcion] AS [descripcion],
		[fecha_inicio] AS [fecha_inicio]
	FROM [pro_SesionActividad]
	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_pro_SesionActividadesXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_pro_SesionActividad]
	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_pro_SesionActividadesXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXusuario_creo_m]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_pro_SesionActividad]
	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_pro_SesionActividadesXactividad_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXactividad_m]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXactividad_m]
	@p_id_actividad INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_pro_SesionActividad]
	WHERE ([id_actividad]= @p_id_actividad)
	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_pro_SesionActividadesXejecutores_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXejecutores_m]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXejecutores_m]
	@p_id_ejecutores INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_pro_SesionActividad]
	WHERE ([id_ejecutores]= @p_id_ejecutores)
	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_pro_SesionActividadesXGrupoSesion_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividadesXGrupoSesion_m]
GO
CREATE PROCEDURE [sel_pro_SesionActividadesXGrupoSesion_m]
	@p_id_GrupoSesion INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_pro_SesionActividad]
	WHERE ([id_GrupoSesion]= @p_id_GrupoSesion)
	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_pro_SesionActividades_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_pro_SesionActividades_m]
GO
CREATE PROCEDURE [sel_pro_SesionActividades_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_pro_SesionActividad]
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_pro_SesionActividades_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_pro_SesionActividades_m]
GO
CREATE PROCEDURE [lis_pro_SesionActividades_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[SesionActividad] AS [pro_SesionActividad]
	FROM [pro_SesionActividad]
	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_pro_SesionActividad]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_pro_SesionActividad]
GO
CREATE PROCEDURE [aud_pro_SesionActividad]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [pro_SesionActividad].id as id_tabla,
	[pro_SesionActividad].id_usuario_modifico as id_usuario_modifico,
	[pro_SesionActividad].id_usuario_creo as id_usuario_creo,
	[pro_SesionActividad].fechaModificacion as fechaModificacion,
	[pro_SesionActividad].fechaCreacion as fechaCreacion,
	[pro_SesionActividad].active as active,
	[pro_SesionActividad].[SesionActividad] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

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