Documentos de Académico
Documentos de Profesional
Documentos de Cultura
2. DIAGNSTICO Y PROBLEMA
6.
ESTRATEGIA DE EJECUCIN
USE [GestionDocumental]
GO
/****** Object: StoredProcedure [dbo].[spConsultarBandejaEntradaPorUsuario] Script Date: 03/18/2016
20:13:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[spConsultarBandejaEntradaPorUsuario]
@usuario int
--spConsultarBandejaEntradaPorUsuario 3
--select * from dbo.tbwbEnvioParaCopia
--select * from dbo.tbwbTipoDocumento
--select * from dbo.tbwbEnvio1Detalle
--select * from dbo.tbwbUser
as
select
g.nenvio as SEC,
(select t.nombre from dbo.tbwbTipoDocumento t where t.id= g.tipo) as TIPO,
g.fecha_ingreso as RECIBIDO,
(select u.apellido+' '+u.nombre from dbo.tbwbUser u where u.id=(select x.usuario from
dbo.tbwbDocumentoEnviado x where x.id=g.nenvio) ) as REMITENTE,
(select UPPER(x.asunto) from dbo.tbwbDocumentoEnviado x where x.id=g.nenvio ) as ASUNTO,
(select case a.status when 1 then 1 else 0 end from dbo.tbwbDocumentoEnviadoAdjunto a where
a.numero_documento=g.nenvio) as ADJUNTO
from dbo.tbwbEnvioParaCopia g,dbo.tbwbDocumentoEnviado x, dbo.tbwbDocumentoEnviadoAdjunto a
where g.receptor=@usuario
and x.id=g.nenvio
and x.borrador=0 and x.enviado=1
union
select
p.nenvio as SEC,
(select t.nombre from dbo.tbwbTipoDocumento t where t.id= p.tipo) as TIPO,
p.fecha_ingreso as RECIBIDO,
(select u.apellido+' '+u.nombre from dbo.tbwbUser u where u.id=(select x.usuario from
dbo.tbwbDocumentoEnviado x where x.id=p.nenvio) ) as REMITENTE,
(select upper(x.asunto) from dbo.tbwbDocumentoEnviado x where x.id=p.nenvio ) as ASUNTO,
(select case a.status when 1 then 1 else 0 end from dbo.tbwbDocumentoEnviadoAdjunto a where
a.numero_documento=p.nenvio) as ADJUNTO
from dbo.tbwbEnvioPara p,dbo.tbwbDocumentoEnviado x
where p.receptor=@usuario
and x.id=p.nenvio
and x.borrador=0 and x.enviado=1
===========================================================