![]() If you do not want to use the PIVOT function, then you can use an aggregate function with a CASE expression: select Select = STUFF((SELECT ',' + QUOTENAME(ColumnName)Įxec sp_executesql Demo. If you have an unknown number of columnnames that you want to transpose, then you can use dynamic SQL: DECLARE AS AS NVARCHAR(MAX) ![]() ![]() In SQL Server you can use the PIVOT function to transform the data from rows to columns: select Firstname, Amount, PostalCode, LastName, AccountNumberįor columnname in (Firstname, Amount, PostalCode, LastName, AccountNumber) There are several ways that you can transform data from multiple rows into columns. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |