Pivot query result (column name will change)

RJ 166 Reputation points
2024-10-02T23:11:44.2633333+00:00

Hi there,

Working on a huge db task. A small part of it is pivoting a query result with dynamic column names.

Example Query:
Select top 1 * from information_schema.columns

Output should be

ColumnName | Value

Thanks

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,770 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.