Show Rows as Columns in SQL Server
You can accomplish this with pivot, when you are dealing with translating the columns into rows you will still need to utilize an aggregate. The pivot has three primary pieces:


Group
Spread
Aggregate




DECLARE @table TABLE (name VARCHAR(255), code INT);

INSERT INTO @table
VALUES ('Test A', 1), ('Test B', 2), ('Test C', 3);

SELECT [1] AS 'Customer', [2] AS 'Fleet', [3] AS 'Account'
FROM @table
PIVOT(MAX(name) FOR code IN (
            [1],
            [2],
            [3]
            )) pvt;


In the working example above we see the grouping as Name and we spread the results of code across three columns with hard coded values. The aggregate is based on the MAX value of name, this is what let's us pivot the row by pivoting on a group with a max value that would only return one row.

Now if you want to create this dynamically vs hardcoding, you'll need to look into dynamic sql.

Here's an article on dynamic pivot sql on MS SQL Tips by Aaron Bertrand