This is not a very polished solution, but it will give you an idea as to how you can achieve this using dynamic SQL.
--** Set up a table to test this with
DECLARE @TestTable TABLE (Field VARCHAR(20), VALUE INT);
INSERT INTO @TestTable (Field, VALUE)
SELECT 'A',1 UNION
SELECT 'B',2 UNION
SELECT 'C',3 UNION
SELECT 'D',4
--** Set up variables
DECLARE @ColCount INT;
DECLARE @Loop INT;
DECLARE @ColName VARCHAR(20);
DECLARE @Value INT;
DECLARE @SQL VARCHAR(255);
--** Create temp table to hold the results and insert the row for populating
CREATE TABLE #ResultSet (dummy INT);
INSERT INTO #ResultSet (dummy) VALUES (0);
--** Get count of required columns
SELECT @ColCount = COUNT(*)
FROM @TestTable AS tt
SET @Loop = 1
WHILE @Loop <= @ColCount BEGIN
--** Get column name and value
WITH Cols AS
(
SELECT tt.Field
, tt.VALUE
, ROW_NUMBER() OVER (ORDER BY tt.Field) AS row
FROM @TestTable AS tt
)
SELECT @ColName = Field
, @Value = Value
FROM Cols
WHERE row = @Loop;
--** Add the column
SET @SQL = 'ALTER TABLE #ResultSet ADD ' + @ColName + ' INT;';
EXEC(@SQL);
--** Insert the value
SET @SQL = 'UPDATE #ResultSet SET ' + @ColName + ' = ' + CONVERT(VARCHAR(50),@Value)
EXEC(@SQL);
SET @Loop = @Loop + 1;
END
--** Drop the dummy column
ALTER TABLE #ResultSet DROP COLUMN [dummy];
SELECT *
FROM #ResultSet;
DROP TABLE #ResultSet;