
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[reg_doc_subtipoDocumento_atributo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_doc_subtipoDocumento_atributo]
GO
CREATE PROCEDURE [reg_doc_subtipoDocumento_atributo]
	@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],
		[subtipoDocumento_atributo] AS [subtipoDocumento_atributo],
		[id_subtipoDocumento] AS [id_subtipoDocumento],
		[id_atributo] AS [id_atributo],
		[orden] AS [orden],
		[mostrarAPI] AS [mostrarAPI]
	FROM [doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributo]')) DROP VIEW [dbo].[view_doc_subtipoDocumento_atributo]
GO
CREATE  VIEW [view_doc_subtipoDocumento_atributo] AS
SELECT 	[doc_subtipoDocumento_atributo].[id] AS [id],
		[doc_subtipoDocumento_atributo].[uid] AS [uid],
		[doc_subtipoDocumento_atributo].[eid] AS [eid],
		[doc_subtipoDocumento_atributo].[id_usuario_modifico] AS [id_usuario_modifico],
		[doc_subtipoDocumento_atributo].[id_usuario_creo] AS [id_usuario_creo],
		[doc_subtipoDocumento_atributo].[fechaModificacion] AS [fechaModificacion],
		[doc_subtipoDocumento_atributo].[fechaCreacion] AS [fechaCreacion],
		[doc_subtipoDocumento_atributo].[active] AS [active],
		[doc_subtipoDocumento_atributo].[subtipoDocumento_atributo] AS [subtipoDocumento_atributo],
		[doc_subtipoDocumento_atributo].[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_atributo].[id_atributo] AS [id_atributo],
[cat_atributo].[atributo] as [cat_atributo_atributo],
[cat_atributo].[atributo_codigo] as [cat_atributo_atributo_codigo],
[cat_atributo].[nombreControl] as [cat_atributo_nombreControl],
[cat_atributo].[esVariable] as [cat_atributo_esVariable],
[cat_atributo].[resaltado] as [cat_atributo_resaltado],
[cat_atributo].[valorMinimo] as [cat_atributo_valorMinimo],
[cat_atributo].[ValorMaximo] as [cat_atributo_ValorMaximo],
[cat_atributo].[id_seccionAtributo] as [cat_atributo_id_seccionAtributo],
[cat_atributo].[id_tipoAtributo] as [cat_atributo_id_tipoAtributo],
[cat_atributo].[id_unidad] as [cat_atributo_id_unidad],
[cat_atributo].[esObligatorio] as [cat_atributo_esObligatorio],
		[doc_subtipoDocumento_atributo].[orden] AS [orden],
		[doc_subtipoDocumento_atributo].[mostrarAPI] AS [mostrarAPI],
		[empresaCodigo].[empresa] As [multiempresa],
gen_unidad.unidad As Unidad
FROM [doc_subtipoDocumento_atributo]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[doc_subtipoDocumento_atributo].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[doc_subtipoDocumento_atributo].[id_usuario_creo]
	INNER JOIN [doc_subtipoDocumento] ON [doc_subtipoDocumento].id=[doc_subtipoDocumento_atributo].[id_subtipoDocumento]
	INNER JOIN [cat_atributo] ON [cat_atributo].id=[doc_subtipoDocumento_atributo].[id_atributo]
INNER JOIN gen_unidad ON gen_unidad.id=cat_atributo.id_unidad	
INNER JOIN [gen_empresa] AS empresaCodigo ON [doc_subtipoDocumento_atributo].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_doc_subtipoDocumento_atributosXusuario_modifico]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXusuario_modifico]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXusuario_modifico]
	@p_id_usuario_modifico INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributosXusuario_creo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXusuario_creo]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXusuario_creo]
	@p_id_usuario_creo INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributosXsubtipoDocumento]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXsubtipoDocumento]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXsubtipoDocumento]
	@p_id_subtipoDocumento INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributosXatributo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXatributo]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXatributo]
	@p_id_atributo INT
AS
BEGIN
	SELECT * 
	FROM [view_doc_subtipoDocumento_atributo]
	WHERE ([id_atributo]= @p_id_atributo)
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_subtipoDocumento_atributos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributos]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributos]
	
	@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_subtipoDocumento_atributo]
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_subtipoDocumento_atributos]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_doc_subtipoDocumento_atributos]
GO
CREATE PROCEDURE [lis_doc_subtipoDocumento_atributos]
	AS
BEGIN
	SELECT id AS id,
[subtipoDocumento_atributo] AS [doc_subtipoDocumento_atributo]
	FROM [doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[upd_doc_subtipoDocumento_atributo]
GO
CREATE PROCEDURE [upd_doc_subtipoDocumento_atributo]
	@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_subtipoDocumento_atributo varchar(8000) = null,
		@p_id_subtipoDocumento int = null,
		@p_id_atributo int = null,
		@p_orden int = null,
		@p_mostrarAPI bit = null
AS
BEGIN
		UPDATE [doc_subtipoDocumento_atributo]
		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(),
			[subtipoDocumento_atributo] = isnull(@p_subtipoDocumento_atributo,[subtipoDocumento_atributo]),
			[id_subtipoDocumento] = isnull(@p_id_subtipoDocumento,[id_subtipoDocumento]),
			[id_atributo] = isnull(@p_id_atributo,[id_atributo]),
			[orden] = isnull(@p_orden,[orden]),
			[mostrarAPI] = isnull(@p_mostrarAPI,[mostrarAPI])
		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_subtipoDocumento_atributo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[ins_doc_subtipoDocumento_atributo]
GO
CREATE PROCEDURE [ins_doc_subtipoDocumento_atributo]
	@p_uid varchar(500),
		@p_eid varchar(50),
		@p_id_usuario_modifico int,
		@p_id_usuario_creo int,
		@p_subtipoDocumento_atributo varchar(8000),
		@p_id_subtipoDocumento int,
		@p_id_atributo int,
		@p_orden int,
		@p_mostrarAPI bit
AS
BEGIN
	DECLARE @v_id int
		INSERT INTO [doc_subtipoDocumento_atributo]
			([uid],
			[eid],
			[id_usuario_modifico],
			[id_usuario_creo],
			[fechaModificacion],
			[fechaCreacion],
			[subtipoDocumento_atributo],
			[id_subtipoDocumento],
			[id_atributo],
			[orden],
			[mostrarAPI])
		VALUES(	@p_uid,
			@p_eid,
			@p_id_usuario_modifico,
			@p_id_usuario_creo,
			GETDATE(),
			GETDATE(),
			@p_subtipoDocumento_atributo,
			@p_id_subtipoDocumento,
			@p_id_atributo,
			@p_orden,
			@p_mostrarAPI)
		SET @v_id = scope_identity()
UPDATE [doc_subtipoDocumento_atributo] 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_subtipoDocumento_atributo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[act_doc_subtipoDocumento_atributo]
GO
CREATE PROCEDURE [act_doc_subtipoDocumento_atributo]
	@p_active BIT,
	@p_id INT,
@p_id_usuario_modifico int = null
AS
BEGIN
	UPDATE [doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[reg_doc_subtipoDocumento_atributo_m]
GO
CREATE PROCEDURE [reg_doc_subtipoDocumento_atributo_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],
		[subtipoDocumento_atributo] AS [subtipoDocumento_atributo],
		[id_subtipoDocumento] AS [id_subtipoDocumento],
		[id_atributo] AS [id_atributo],
		[orden] AS [orden],
		[mostrarAPI] AS [mostrarAPI]
	FROM [doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributosXusuario_modifico_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXusuario_modifico_m]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXusuario_modifico_m]
	@p_id_usuario_modifico INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributosXusuario_creo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXusuario_creo_m]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXusuario_creo_m]
	@p_id_usuario_creo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributosXsubtipoDocumento_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXsubtipoDocumento_m]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXsubtipoDocumento_m]
	@p_id_subtipoDocumento INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributosXatributo_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributosXatributo_m]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributosXatributo_m]
	@p_id_atributo INT,
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT *
	FROM [view_doc_subtipoDocumento_atributo]
	WHERE ([id_atributo]= @p_id_atributo)
	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_subtipoDocumento_atributos_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[sel_doc_subtipoDocumento_atributos_m]
GO
CREATE PROCEDURE [sel_doc_subtipoDocumento_atributos_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_subtipoDocumento_atributo]
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_subtipoDocumento_atributos_m]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[lis_doc_subtipoDocumento_atributos_m]
GO
CREATE PROCEDURE [lis_doc_subtipoDocumento_atributos_m]
	@p_eid as varchar(50) = ''
AS
BEGIN
	SELECT id AS id,
[subtipoDocumento_atributo] AS [doc_subtipoDocumento_atributo]
	FROM [doc_subtipoDocumento_atributo]
	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_subtipoDocumento_atributo]') AND type in (N'P', N'PC'))DROP PROCEDURE [dbo].[aud_doc_subtipoDocumento_atributo]
GO
CREATE PROCEDURE [aud_doc_subtipoDocumento_atributo]
	@p_filtro as varchar (8000) = '1=1'
AS
BEGIN
exec(	'SELECT [doc_subtipoDocumento_atributo].id as id_tabla,
	[doc_subtipoDocumento_atributo].id_usuario_modifico as id_usuario_modifico,
	[doc_subtipoDocumento_atributo].id_usuario_creo as id_usuario_creo,
	[doc_subtipoDocumento_atributo].fechaModificacion as fechaModificacion,
	[doc_subtipoDocumento_atributo].fechaCreacion as fechaCreacion,
	[doc_subtipoDocumento_atributo].active as active,
	[doc_subtipoDocumento_atributo].[subtipoDocumento_atributo] as campoPrincipal,
	[seg_usuario_creo].usuario as usuarioCreo,
	[seg_usuario_modifico].usuario as usuarioModifico

	FROM [doc_subtipoDocumento_atributo]
	INNER JOIN [seg_usuario] AS [seg_usuario_modifico] ON [seg_usuario_modifico].id=[doc_subtipoDocumento_atributo].[id_usuario_modifico]
	INNER JOIN [seg_usuario] AS [seg_usuario_creo] ON [seg_usuario_creo].id=[doc_subtipoDocumento_atributo].[id_usuario_creo]
	where ' + @p_filtro)
END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON
GO
----------------------
print 'doc_subtipoDocumento_atributo'
-----------------------------------11/05/2021 9:27:35 a. m.