Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Analysis Server and Reporting Services (2012)
 Query to tansform rows to colums

Author  Topic 

sukantisonline
Starting Member

1 Post

Posted - 2014-05-19 : 07:17:46
Hi,

I am having problems to transform rows to columns - as the final output needs to be shown in columns. Can anyone please suggest me a quick way to do that by writing some SQL query? The final output needs to be shown on BI data visualisation software and the query needs to be written on SQL. I need this asap as the work needs to be delivered in couple of hours time.
Quick help is much appreciated.

Thanks
Sukant

Sukant

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-05-19 : 11:02:27
You can use the PIVOT operator if the columns are known in advance - see here for documentation and examples: http://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx

If you don't know the columns in advance, you will need to use dynamic pivot. See here for one way of doing it: http://beyondrelational.com/modules/2/blogs/70/posts/10840/dynamic-pivot-in-sql-server-2005.aspx
Go to Top of Page
   

- Advertisement -