Unpivot table with multiple columns and dynamic column names
问题 I am trying to unpivot a table with multiple rows and columns. Each row needs to be extratced to 2 rows with specific columns and the column names need to be renamed and a new column needs to added based on the columns selected! I am including before and after sample data and a script to setup the data. CREATE TABLE #tmpProducts ( ProductId INT, ProductName nVARCHAR(100), B2B_GrossRevenue DECIMAL(10,2), B2B_DirectCost DECIMAL(10,2), B2B_NetRevenue DECIMAL(10,2), B2C_GrossRevenue DECIMAL(10,2)