Matrix-Ergebnis mit SQL Server 2008 R2

Ich habe eine Tabelle wie folgt:

Beispie:

CREATE TABLE matrix
(
  a VARCHAR(10),
  b VARCHAR(10)
);

INSERT INTO matrix VALUES('A','H')
INSERT INTO matrix VALUES('B','I')
INSERT INTO matrix VALUES('C','J')
INSERT INTO matrix VALUES('D','K')
INSERT INTO matrix VALUES('E','L')
INSERT INTO matrix VALUES('F','M')
INSERT INTO matrix VALUES('G','N')
INSERT INTO matrix VALUES('A','M')

SELECT * FROM matrix;

Sieht aus wie

a    b
-------
A    H
B    I
C    J
D    K
E    L
F    M
G    N
A    M

Jetzt möchte ich das Ergebnis in folgendem Matrixformat anzeigen:

Erwartetes Ergebnis

     H    I    J    K    L    M    N
 --------------------------------------
 A | 1    0    0    0    0    1    0
   | 
 B | 0    1    0    0    0    0    0
   |
 C | 0    0    1    0    0    0    0
   |
 D | 0    0    0    1    0    0    0
   |
 E | 0    0    0    0    1    0    0
   |
 F | 0    0    0    0    0    1    0
   |
 G | 0    0    0    0    0    0    1

Antworten auf die Frage(1)

Ihre Antwort auf die Frage