MS SQL Server 2005 - Verkettung mit FOR XML PATH Probleme mit Feld, das Source heisst
Ich habe einen funktionierenden XML Path Ausdruck, der mehrere Felder aus der DB in einer Spalte zusammenfügt. Füge ich dort aber noch das Feld Source hinzu, wird nur das erste Element der Verkettung mit Sourcewert ausgegeben
select
reasontext + ' (' + 'erstellt am: ' + convert(varchar(10),creationdate,104) + ' ' + convert(varchar(8), creationdate, 108) +
-- InformationSource hinzugefügt
' InformationSource: ' +
-- das geht
--convert(varchar(100),3) +
-- das nicht
--convert(varchar(100), Source) +
')'
+ ', '
from mytable
FOR XML PATH('')
In Source (int) steht z. B. auch nur die 3 drin.
Im auskommentierten Zustand von Source kommt z. B. das raus:
Reason1 (erstellt am: 03.03.2010 09:13:00 InformationSource: ), Reason 2 (erstellt am: 16.07.2010 11:57:00 InformationSource: ), Reason3 (erstellt am: 20.07.2010 11:19:00 InformationSource: ),
Kommentiere ich die Source - Zeile ein, dann ist das Ergebnis nur:
Reason1 (erstellt am: 03.03.2010 09:13:00 InformationSource: 3,
Das Problem scheint das Feld Source zu sein (die Bezeichnung?).
Kann ich das irgendwie umgehen?
Danke schon mal für die Hilfe!
reasontext + ' (' + 'erstellt am: ' + convert(varchar(10),creationdate,104) + ' ' + convert(varchar(8), creationdate, 108) +
-- InformationSource hinzugefügt
' InformationSource: ' +
-- das geht
--convert(varchar(100),3) +
-- das nicht
--convert(varchar(100), Source) +
')'
+ ', '
from mytable
FOR XML PATH('')
In Source (int) steht z. B. auch nur die 3 drin.
Im auskommentierten Zustand von Source kommt z. B. das raus:
Reason1 (erstellt am: 03.03.2010 09:13:00 InformationSource: ), Reason 2 (erstellt am: 16.07.2010 11:57:00 InformationSource: ), Reason3 (erstellt am: 20.07.2010 11:19:00 InformationSource: ),
Kommentiere ich die Source - Zeile ein, dann ist das Ergebnis nur:
Reason1 (erstellt am: 03.03.2010 09:13:00 InformationSource: 3,
Das Problem scheint das Feld Source zu sein (die Bezeichnung?).
Kann ich das irgendwie umgehen?
Danke schon mal für die Hilfe!
Please also mark the comments that contributed to the solution of the article
Content-Key: 153589
Url: https://administrator.de/contentid/153589
Printed on: April 19, 2024 at 18:04 o'clock
1 Comment