DROP VIEW LD0VAA0DocumentRegular
;
CREATE VIEW LD0VAA0DocumentRegular
AS
SELECT        T41.DOKUMENTNR, T41.AGARNR, T41.AGARTYP, T41.DDATUM, T41.DRUBRIK, T41.DOKID, T41.UPDDAT, T41.UPDSIGN, T41.UTLINSNR, T41.DOCTYPE, T41.ACTIVE, 
                         T41.DOKTYP, T41.PERSONNR, T41.DELETED, T41.LNDOKTYP, T41.HUVUDOBJTYP, T41.HUVUDOBJNR, T41.VERSIONNR, T41.ANSVHAND, T41.ANSVTITEL, 
                         T41.ANTDOKTYP, T41.EBREV_SENDDATE, T41.EBREV_SENDTIME, T41.EBREV_SENDSIGN, T41.EBREV_SENDACK, T41.HANDELSEDATE, T41.LOCKED, 
                         T41.LOCKDATE, T41.LOCKSIGN, Q01.KLARTEXT AS DOKTYP_T, TXT.TEXTID, A.NAMN, Q01.XNUM28 AS CANCHANGEOCCURENCEDATE, Q01.XNUM4 AS BLANKETT,
						 T41.LIFECARE_CREATED
FROM LD0V0T41 AS T41 
INNER JOIN LD0V0Q01 Q01 
ON T41.DOKTYP = Q01.KOD 
AND Q01.KODTYP = 'TYPDOK' 
INNER JOIN GA1V0TXT TXT 
ON '7255.' + CONVERT(VARCHAR(32), T41.DOKUMENTNR) = TXT.OBJEKTID 
AND TXT.DELETED = 0 
INNER JOIN LD0V0A A 
ON T41.PERSONNR = A.PNR
WHERE T41.LIFECARE_CREATED = 1
;