Try this:
DECLARE @cols NVARCHAR(200)
DECLARE @dt NVARCHAR(1000)
DECLARE @pt NVARCHAR(2000)
SET @cols = STUFF((SELECT DISTINCT '],[' + F
FROM YourDataBase
ORDER BY '],[' + F
FOR XML PATH('')),1,2,'') + ']'
SET @dt = 'SELECT * ' +
'FROM YourTable'
SET @pt = 'SELECT ID, ' + @cols + ' ' +
'FROM (' + @dt + ') AS DT ' +
'PIVOT(MAX(F) FOR(ID) IN (' + @cols + ')) AS PT ' +
'ORDER BY ID'
EXEC (@pt)