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)
 CASE or PIVOT? Which is better?

Author  Topic 

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2010-12-21 : 02:01:39
Hello All,

I have million records in table A and million in table B and joining these two tables to get some crazy output for analysis(combining 3 records as a single record). So which ones might be more useful? CASE or PIVOT?

Thanks.

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2010-12-21 : 03:49:31
Pivot, as it present data in a better way
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-12-21 : 06:44:37
Without seeing actual data and the results you want, there's no way to answer this question.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-12-21 : 07:03:26
CASE is slightly faster and more versatile.
All columns created by PIVOT need to be same database, whereas CASE allow different datatype per column.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-12-21 : 07:18:29
quote:
All columns created by PIVOT need to be same database....


I think Peso means datatype.

PBUH

Go to Top of Page
   

- Advertisement -