Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
T-SQL (SS2K8)
»
Pivot And Unpivot Table
12 posts, Page 1 of 2
1
2
»»
Pivot And Unpivot Table
Rate Topic
Display Mode
Topic Options
Author
Message
Shadab Shah
Shadab Shah
Posted Friday, August 03, 2012 5:07 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: 2 days ago @ 6:48 AM
Points: 160,
Visits: 334
Hi,
I am a newbie in sql server.I have came across various article on internet which shows how to implement pivot and un-pivot table. Since there are various gurus of sql server in this forum, i would like to know from them wheather they had used this feature in any of there project. And even though if you had used the above feature what would have being the alternate solution to the problem if you had being not using this feature.
Post #1339734
SomewhereSomehow
SomewhereSomehow
Posted Friday, August 03, 2012 5:22 AM
SSC Journeyman
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 10:52 PM
Points: 75,
Visits: 410
When you asking about alternate solution you, do mean funtctional equivalent? you may use case+group by instead of pivot, and cross apply instead of unpivot. You may also check out these article about
unpivot
.
I am really sorry for my poor gramma. And I hope that value of my answers will outweigh the harm for your eyes.
Blog: http://somewheresomehow.ru
Twitter: @SomewereSomehow
Post #1339740
Shadab Shah
Shadab Shah
Posted Friday, August 03, 2012 6:33 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: 2 days ago @ 6:48 AM
Points: 160,
Visits: 334
yeah i was expecting functional requriment. But again the new question that comes to mind is if we do have an alternate solution then why unpivot and pivot.
Since i am new to SQL Server just curios to know it
Post #1339778
Kirby1367
Kirby1367
Posted Friday, August 03, 2012 6:45 AM
Forum Newbie
Group: General Forum Members
Last Login: Monday, October 22, 2012 12:21 PM
Points: 4,
Visits: 40
In the past I have used PIVOT/ UNPIVOT along side dynamic SQL mainly in ETL scripts.
For example I was importing data that was stored in columns and needed it in a single row in the target DB.
Post #1339784
vinu512
vinu512
Posted Saturday, August 04, 2012 4:13 AM
Ten Centuries
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:11 AM
Points: 1,042,
Visits: 1,438
Using Pivot/unpivot could be more than just a matter of choice. You can definitely avoid the Pivot with Case+Group but then you come across situations where you can't use Case+Group. This could be because the columns are not Static and you need to get the Columns Dynamically.
In these situations you can't avoid the Pivot and have to go with a
Dynamic CrossTab
.
For other situations it is a matter of choice and can be avoided.
Vinu Vijayan
For better and faster solutions please check...
"How to post data/code on a forum to get the best help" - Jeff Moden
Post #1340177
dwain.c
dwain.c
Posted Monday, August 06, 2012 7:04 PM
SSCrazy
Group: General Forum Members
Last Login: Today @ 5:54 PM
Points: 2,338,
Visits: 3,160
SomewhereSomehow (8/3/2012)
When you asking about alternate solution you, do mean funtctional equivalent? you may use case+group by instead of pivot, and cross apply instead of unpivot. You may also check out these article about
unpivot
.
Wow! You quoted me!
Thanks for taking the time to read my article. I was wondering who that was.
No loops! No CURSORs! No RBAR! Hoo-uh!
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1340963
vinu512
vinu512
Posted Monday, August 06, 2012 10:21 PM
Ten Centuries
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:11 AM
Points: 1,042,
Visits: 1,438
dwain.c (8/6/2012)
SomewhereSomehow (8/3/2012)
When you asking about alternate solution you, do mean funtctional equivalent? you may use case+group by instead of pivot, and cross apply instead of unpivot. You may also check out these article about
unpivot
.
Wow! You quoted me!
Thanks for taking the time to read my article. I was wondering who that was.
Wow!!....Don't forget me Dwain now that you have become all famous after writing that article.....lol
Vinu Vijayan
For better and faster solutions please check...
"How to post data/code on a forum to get the best help" - Jeff Moden
Post #1340988
dwain.c
dwain.c
Posted Monday, August 06, 2012 10:25 PM
SSCrazy
Group: General Forum Members
Last Login: Today @ 5:54 PM
Points: 2,338,
Visits: 3,160
vinu512 (8/6/2012)
dwain.c (8/6/2012)
SomewhereSomehow (8/3/2012)
When you asking about alternate solution you, do mean funtctional equivalent? you may use case+group by instead of pivot, and cross apply instead of unpivot. You may also check out these article about
unpivot
.
Wow! You quoted me!
Thanks for taking the time to read my article. I was wondering who that was.
Wow!!....Don't forget me Dwain now that you have become all famous after writing that article.....lol
How could I forget you Vinu, despite the fame and glory of being published! Now, all that awaits is the fortune coming my way and I'll be set.
No loops! No CURSORs! No RBAR! Hoo-uh!
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1340989
vinu512
vinu512
Posted Monday, August 06, 2012 10:35 PM
Ten Centuries
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:11 AM
Points: 1,042,
Visits: 1,438
dwain.c (8/6/2012)
vinu512 (8/6/2012)
dwain.c (8/6/2012)
SomewhereSomehow (8/3/2012)
When you asking about alternate solution you, do mean funtctional equivalent? you may use case+group by instead of pivot, and cross apply instead of unpivot. You may also check out these article about
unpivot
.
Wow! You quoted me!
Thanks for taking the time to read my article. I was wondering who that was.
Wow!!....Don't forget me Dwain now that you have become all famous after writing that article.....lol
How could I forget you Vinu, despite the fame and glory of being published! Now, all that awaits is the fortune coming my way and I'll be set.
All my wishes are with you Dwain....keep learning and keep writing stuff like that so that Learners like me can learn from your Experiences....All the Best!!
Vinu Vijayan
For better and faster solutions please check...
"How to post data/code on a forum to get the best help" - Jeff Moden
Post #1340992
dwain.c
dwain.c
Posted Monday, August 06, 2012 10:38 PM
SSCrazy
Group: General Forum Members
Last Login: Today @ 5:54 PM
Points: 2,338,
Visits: 3,160
What? You mean you read it too, Vinu?
An interesting use case just appeared here:
http://www.sqlservercentral.com/Forums/Topic1339633-392-3.aspx#bm1340977
The discussion thread also sheds further light on its performance, just in case you didn't go through it. There's some more research to do, but it looks pretty good overall on performance.
No loops! No CURSORs! No RBAR! Hoo-uh!
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1340994
« Prev Topic
|
Next Topic »
12 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.