#Parameter1:Journal:DataTable:select nreintrag as keyvalue, convert(varchar(10),erstellt_am,104) FROM camt_Run ORDER BY nreintrag desc, erstellt_am desc 
-SQL-
SELECT        dbo.CAMT_Run.NrEIntrag AS CAMT_RUN_NrEintrag, dbo.CAMT_Run.Datum AS CAMT_Run_Datum, dbo.CAMT_Run.aktiv AS CAMT_Run_Aktiv, dbo.CAMT_Run.erstellt_am AS CAMT_Run_Erstelltam, 
                         dbo.CAMT_Run.mutiert_am AS CAMT_Run_Mutiertam, dbo.CAMT_Run.mutierer AS CAMT_Run_Mutierer, dbo.CAMT_Run.Sourcefilename AS CAMT_Run_Filename, dbo.CAMT_File.Nreintrag AS CAMT_File_Nreintrag, 
                         dbo.CAMT_File.CAMT_RunNr AS CAMT_File_CAMT_Run_NrEintrag, dbo.CAMT_File.Filename AS CAMT_File_Filename, dbo.CAMT_File.CreateDateTime AS CAMT_File_CreateDateTime, dbo.CAMT_File.IBAN AS CAMT_File_IBSN, 
                         dbo.CAMT_File.REF AS CAMT_File_Referenz, dbo.CAMT_File.Anzahl_Buchungen AS CAMT_File_Anzhal_Buchungen, dbo.CAMT_File.ID AS CAMT_File_ID, dbo.CAMT_File.Total AS CAMT_File_Total, 
                         dbo.CAMT_File.aktiv AS CAMT_File_Aktiv, dbo.CAMT_File.erstellt_am AS CAMT_File_Erstellt_am, dbo.CAMT_File.mutiert_am AS CAMT_File_Mutiert_am, dbo.CAMT_File.mutierer AS CAMT_File_Mutierer, 
                         dbo.CAMT_Record.nreintrag AS CAMT_Record_NrEintrag, dbo.CAMT_Record.CAMT_FileNr AS CAMT_Record_CAMT_Filen_NrEintrag, dbo.CAMT_Record.Referenz AS CAMT_Record_Referenz, 
                         dbo.CAMT_Record.Valuta AS CAMT_Record_Valuta, dbo.CAMT_Record.Buchungsdatum AS CAMT_Record_Buchungsdatum, dbo.CAMT_Record.Betrag AS CAMT_Record_Betrag, dbo.CAMT_Record.Taxen AS CAMT_Record_Taxen,
                          dbo.CAMT_Record.aktiv AS CAMT_Record_Aktiv, dbo.CAMT_Record.erstellt_am AS CAMT_Record_erstellt_am, dbo.CAMT_Record.mutiert_am AS CAMT_Record_Mutiert_am, 
                         dbo.CAMT_Record.mutierer AS CAMT_Record_Mutierer, dbo.CAMT_Record.verbucht AS CAMT_Record_Verbucht, SUBSTRING(dbo.CAMT_Record.Referenz, 7, 10) AS fakturanr, dbo.get_name(dbo.Faktura.Nrpatient) AS Patient, 
                         dbo.get_name(dbo.Faktura.Nrdebitor) AS Debitor
FROM            dbo.CAMT_Run INNER JOIN
                         dbo.CAMT_File ON dbo.CAMT_Run.NrEIntrag = dbo.CAMT_File.CAMT_RunNr INNER JOIN
                         dbo.CAMT_Record ON dbo.CAMT_File.Nreintrag = dbo.CAMT_Record.CAMT_FileNr LEFT OUTER JOIN
                         dbo.Faktura ON SUBSTRING(dbo.CAMT_Record.Referenz, 7, 10) = dbo.Faktura.Nrfaktura
WHERE        (dbo.CAMT_Run.NrEIntrag = #Parameter1)

