I am using SQL Server 2000. My table show data like when I issue SQL like
select * from mytable
TotalSale RemanSale DiagSale TotalCall CountryCode
---------- --------- -------- --------- -----------
16200 11100 5600 7 GB
15620 10100 4100 8 US
I want to show the above data like this:
Fields Value CountryCode
------ ------ ------------
TotalSale 16200 GB
RemanSale 11100 GB
DiagSale 5600 GB
TotalCall 7 GB
TotalSale 15620 US
RemanSale 10100 US
DiagSale 4100 US
TotalCall 8 US
If possible then also give me code in terms of SQL Server 2005 using pivot function.
First give me the code for SQL Server 2000 because I am using SQL Server 2000 and after that if possible then write down the same code for SQL Server 2005 using pivot function
thanks
Take a look at the pivot feature, I think that would solve you’re problem. For the SQL Server 2k you need to look into dynamic sql generation.