Hallo ich habe eine
MSSQL Tabelle in diesen Format (kann nicht geändert werden)
Code:
[Objekt] [Atribut] [Value]
Müller City City1
Müller Street Street1
Müller Num 1234
Mayer City City2
Mayer Street Street2
Mayer Num 4321
Was ist der Beste Weg um dies zu bekommen?
Code:
[Objekt] [Street] [City] [Number]
Mayer Street2 City2 4321
Müller Street1 City1 1234
bisher löse ich es so:
Code:
DECLARE @allObj TABLE ( Objekt NVARCHAR(12))
INSERT @allObj
SELECT Objekt FROM Table_1_Test group by Objekt
SELECT Tab2.Objekt,
(SELECT [Value] FROM [Table_1_Test] WHERE [Objekt] = Tab2.Objekt AND [Atribut] = 'Street') AS [Street],
(SELECT [Value] FROM [Table_1_Test] WHERE [Objekt] = Tab2.Objekt AND [Atribut] = 'City') AS [City],
(SELECT [Value] FROM [Table_1_Test] WHERE [Objekt] = Tab2.Objekt AND [Atribut] = 'Num') AS [Number]
From @allObj as Tab2
hat jemand ne bessere Möglichkeit?