The detailed explanation could be found on Red Gate SimpleTalk's link 'An Easier Way of Transposing Query Result in SQL Server' https://www.red-gate.com/simple-talk/sql/t-sql-programming/easier-way-transposing-query-result-sql-server/
-EXEC MATRIX.TRANSPOSING @query = N'SELECT * FROM SYS.DATABASES';
✅ To save transposing query results in a temporary or permanent table.
+The table will be created inside the stored procedure, and after that, you have to drop the table manually. +There is no need to create a temporary or a permanent table first. +The whole task is accomplished inside the stored procedure. +The account that executes stored procedure has to have "CREATE TABLE permission."
The detailed explanation could be found on Red Gate SimpleTalk's link 'An Easier Way of Transposing Query Result in SQL Server' https://www.red-gate.com/simple-talk/sql/t-sql-programming/easier-way-transposing-query-result-sql-server/