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 2005 Forums
 Transact-SQL (2005)
 Equivalents to PIVOT

Author  Topic 

mrm23
Posting Yak Master

198 Posts

Posted - 2010-04-08 : 01:40:46
Hi,
I have a query which selects nearly 30 columns.
of these 20 columns are pivoted useing case/isnull statements.

it seems like:
ISNULL(Cast((Select Amount From HC_RESUME_SALARY_STRUCTURE WITH(NOLOCK)
Where ResumeID = a.ResID And HeaderItemID = '13')as nVarChar),'') as 'Basic'

There are 20 such statements.
I have to tune the query now.
How else can i achieve the same? I dont think pivot will work as i have columns from other tables and these statements have aliases...

Help me.
Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-08 : 05:16:56
show some sample data from table and explain what you want as output

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-08 : 05:25:34
Refer this
http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -