

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_doc_prioridadSubtipoDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_doc_prioridadSubtipoDocumento]
GO
CREATE PROCEDURE [reg_doc_prioridadSubtipoDocumento]
	@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],
		[prioridadSubtipoDocumento] AS [prioridadSubtipoDocumento],
		[prioridadSubtipoDocumento_codigo] AS [prioridadSubtipoDocumento_codigo],
		[id_subtipoDocumento] AS [id_subtipoDocumento],
		[id_prioridadDocumento] AS [id_prioridadDocumento]
	FROM [doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumento]')) DROP VIEW [dbo].[view_doc_prioridadSubtipoDocumento]
GO
CREATE  VIEW [view_doc_prioridadSubtipoDocumento] AS
SELECT 	[doc_prioridadSubtipoDocumento].[id] AS [id],
		[doc_prioridadSubtipoDocumento].[uid] AS [uid],
		[doc_prioridadSubtipoDocumento].[eid] AS [eid],
		[doc_prioridadSubtipoDocumento].[id_usuario_modifico] AS [id_usuario_modifico],
		[doc_prioridadSubtipoDocumento].[id_usuario_creo] AS [id_usuario_creo],
		[doc_prioridadSubtipoDocumento].[fechaModificacion] AS [fechaModificacion],
		[doc_prioridadSubtipoDocumento].[fechaCreacion] AS [fechaCreacion],
		[doc_prioridadSubtipoDocumento].[active] AS [active],
		[doc_prioridadSubtipoDocumento].[prioridadSubtipoDocumento] AS [prioridadSubtipoDocumento],
		[doc_prioridadSubtipoDocumento].[prioridadSubtipoDocumento_codigo] AS [prioridadSubtipoDocumento_codigo],
		[doc_prioridadSubtipoDocumento].[id_subtipoDocumento] AS [id_subtipoDocumento],
[doc_subtipoDocumento].[subtipoDocumento] as [doc_subtipoDocumento_subtipoDocumento],
[doc_subtipoDocumento].[subtipoDocumento_codigo] as [doc_subtipoDocumento_subtipoDocumento_codigo],
[doc_subtipoDocumento].[prefijo] as [doc_subtipoDocumento_prefijo],
[doc_subtipoDocumento].[consecutivo] as [doc_subtipoDocumento_consecutivo],
[doc_subtipoDocumento].[id_tipoDocumento] as [doc_subtipoDocumento_id_tipoDocumento],
[doc_subtipoDocumento].[programarPlaneadas] as [doc_subtipoDocumento_programarPlaneadas],
[doc_subtipoDocumento].[cargarSolicitante] as [doc_subtipoDocumento_cargarSolicitante],
[doc_subtipoDocumento].[verCentroCosto] as [doc_subtipoDocumento_verCentroCosto],
[doc_subtipoDocumento].[verIncoterm] as [doc_subtipoDocumento_verIncoterm],
[doc_subtipoDocumento].[valUrgente] as [doc_subtipoDocumento_valUrgente],
[doc_subtipoDocumento].[bloquearDespacho] as [doc_subtipoDocumento_bloquearDespacho],
[doc_subtipoDocumento].[cerrarSol] as [doc_subtipoDocumento_cerrarSol],
[doc_subtipoDocumento].[ejecutaDevolucion] as [doc_subtipoDocumento_ejecutaDevolucion],
[doc_subtipoDocumento].[tipoCobro] as [doc_subtipoDocumento_tipoCobro],
[doc_subtipoDocumento].[mostrarPendienteDocumento] as [doc_subtipoDocumento_mostrarPendienteDocumento],
[doc_subtipoDocumento].[cantidadAuxiliar] as [doc_subtipoDocumento_cantidadAuxiliar],
		[doc_prioridadSubtipoDocumento].[id_prioridadDocumento] AS [id_prioridadDocumento],
[doc_prioridadDocumento].[prioridadDocumento] as [doc_prioridadDocumento_prioridadDocumento],
[doc_prioridadDocumento].[prioridadDocumento_codigo] as [doc_prioridadDocumento_prioridadDocumento_codigo],
[doc_prioridadDocumento].[tiempoRespuesta] as [doc_prioridadDocumento_tiempoRespuesta],
[doc_prioridadDocumento].[id_tipoDocumento] as [doc_prioridadDocumento_id_tipoDocumento],
[doc_prioridadDocumento].[id_estrategiaPrioridad] as [doc_prioridadDocumento_id_estrategiaPrioridad],
[doc_prioridadDocumento].[orden] as [doc_prioridadDocumento_orden],
		[empresaCodigo].[empresa] As [multiempresa]
FROM [doc_prioridadSubtipoDocumento]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[doc_prioridadSubtipoDocumento].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[doc_prioridadSubtipoDocumento].[id_usuario_creo]
	INNER JOIN [doc_subtipoDocumento] ON [doc_subtipoDocumento].id=[doc_prioridadSubtipoDocumento].[id_subtipoDocumento]
	INNER JOIN [doc_prioridadDocumento] ON [doc_prioridadDocumento].id=[doc_prioridadSubtipoDocumento].[id_prioridadDocumento]
	INNER JOIN [gen_empresa] AS empresaCodigo ON [doc_prioridadSubtipoDocumento].eid = [empresaCodigo].[codigo] and empresaCodigo.active=1
WHERE [doc_prioridadSubtipoDocumento].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_doc_prioridadSubtipoDocumentosXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXusuario_modifico]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumentosXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXusuario_creo]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumentosXsubtipoDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXsubtipoDocumento]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXsubtipoDocumento]
	@p_id_subtipoDocumento INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_prioridadSubtipoDocumento]
	WHERE ([id_subtipoDocumento]= @p_id_subtipoDocumento)
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_doc_prioridadSubtipoDocumentosXprioridadDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXprioridadDocumento]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXprioridadDocumento]
	@p_id_prioridadDocumento INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_prioridadSubtipoDocumento]
	WHERE ([id_prioridadDocumento]= @p_id_prioridadDocumento)
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_doc_prioridadSubtipoDocumentos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentos]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentos]
	
	@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_doc_prioridadSubtipoDocumento]
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_doc_prioridadSubtipoDocumentos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_doc_prioridadSubtipoDocumentos]
GO
CREATE PROCEDURE [lis_doc_prioridadSubtipoDocumentos]
	AS
BEGIN
	SELECT id AS id,
[prioridadSubtipoDocumento] AS [doc_prioridadSubtipoDocumento]
	FROM [doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_doc_prioridadSubtipoDocumento]
GO
CREATE PROCEDURE [upd_doc_prioridadSubtipoDocumento]
	@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_prioridadSubtipoDocumento varchar(300) = null,
		@p_prioridadSubtipoDocumento_codigo varchar(100) = null,
		@p_id_subtipoDocumento int = null,
		@p_id_prioridadDocumento int = null
AS
BEGIN
		UPDATE [doc_prioridadSubtipoDocumento]
		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(),
			[prioridadSubtipoDocumento] = isnull(@p_prioridadSubtipoDocumento,[prioridadSubtipoDocumento]),
			[prioridadSubtipoDocumento_codigo] = isnull(@p_prioridadSubtipoDocumento_codigo,[prioridadSubtipoDocumento_codigo]),
			[id_subtipoDocumento] = isnull(@p_id_subtipoDocumento,[id_subtipoDocumento]),
			[id_prioridadDocumento] = isnull(@p_id_prioridadDocumento,[id_prioridadDocumento])
		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_doc_prioridadSubtipoDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_doc_prioridadSubtipoDocumento]
GO
CREATE PROCEDURE [ins_doc_prioridadSubtipoDocumento]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_prioridadSubtipoDocumento varchar(300),
		@p_prioridadSubtipoDocumento_codigo varchar(100),
		@p_id_subtipoDocumento int,
		@p_id_prioridadDocumento int
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [doc_prioridadSubtipoDocumento]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[prioridadSubtipoDocumento],
			[prioridadSubtipoDocumento_codigo],
			[id_subtipoDocumento],
			[id_prioridadDocumento])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_prioridadSubtipoDocumento,
			@p_prioridadSubtipoDocumento_codigo,
			@p_id_subtipoDocumento,
			@p_id_prioridadDocumento)
		SET @v_id = scope_identity()
UPDATE [doc_prioridadSubtipoDocumento] 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_doc_prioridadSubtipoDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_doc_prioridadSubtipoDocumento]
GO
CREATE PROCEDURE [act_doc_prioridadSubtipoDocumento]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumento_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_doc_prioridadSubtipoDocumento_m]
GO
CREATE PROCEDURE [reg_doc_prioridadSubtipoDocumento_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],
		[prioridadSubtipoDocumento] AS [prioridadSubtipoDocumento],
		[prioridadSubtipoDocumento_codigo] AS [prioridadSubtipoDocumento_codigo],
		[id_subtipoDocumento] AS [id_subtipoDocumento],
		[id_prioridadDocumento] AS [id_prioridadDocumento]
	FROM [doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumentosXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumentosXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXusuario_creo_m]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumentosXsubtipoDocumento_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXsubtipoDocumento_m]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXsubtipoDocumento_m]
	@p_id_subtipoDocumento INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_prioridadSubtipoDocumento]
	WHERE ([id_subtipoDocumento]= @p_id_subtipoDocumento)
	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_doc_prioridadSubtipoDocumentosXprioridadDocumento_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentosXprioridadDocumento_m]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentosXprioridadDocumento_m]
	@p_id_prioridadDocumento INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_prioridadSubtipoDocumento]
	WHERE ([id_prioridadDocumento]= @p_id_prioridadDocumento)
	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_doc_prioridadSubtipoDocumentos_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_prioridadSubtipoDocumentos_m]
GO
CREATE PROCEDURE [sel_doc_prioridadSubtipoDocumentos_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_doc_prioridadSubtipoDocumento]
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_doc_prioridadSubtipoDocumentos_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_doc_prioridadSubtipoDocumentos_m]
GO
CREATE PROCEDURE [lis_doc_prioridadSubtipoDocumentos_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[prioridadSubtipoDocumento] AS [doc_prioridadSubtipoDocumento]
	FROM [doc_prioridadSubtipoDocumento]
	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_doc_prioridadSubtipoDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_doc_prioridadSubtipoDocumento]
GO
CREATE PROCEDURE [aud_doc_prioridadSubtipoDocumento]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [doc_prioridadSubtipoDocumento].id as id_tabla,
	[doc_prioridadSubtipoDocumento].id_usuario_modifico as id_usuario_modifico,
	[doc_prioridadSubtipoDocumento].id_usuario_creo as id_usuario_creo,
	[doc_prioridadSubtipoDocumento].fechaModificacion as fechaModificacion,
	[doc_prioridadSubtipoDocumento].fechaCreacion as fechaCreacion,
	[doc_prioridadSubtipoDocumento].active as active,
	[doc_prioridadSubtipoDocumento].[prioridadSubtipoDocumento] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

	FROM [doc_prioridadSubtipoDocumento]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[doc_prioridadSubtipoDocumento].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[doc_prioridadSubtipoDocumento].[id_usuario_creo]
	where ' + @p_filtro)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
print 'doc_prioridadSubtipoDocumento'
-----------------------------------19/10/2021 16:45:09