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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Looking for the solution
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

venkachi
Starting Member

India
1 Posts

Posted - 04/17/2013 :  04:07:13  Show Profile  Reply with Quote
actually my table data is

Key value
firstname surya
firstname rakhi
firstname venkat
firstname shankar
firstname dany

I want to disply like
firstname
surya
rakhi
venkat
shankar
dany


i write the below query

SELECT firstname
FROM test pvt
PIVOT (MAX(pvt.value ) FOR pvt.key1 IN (firstname)) AS P

but it showing

firstname
venkat


Please help to solve this

satheesh
Posting Yak Master

United Kingdom
152 Posts

Posted - 04/17/2013 :  05:45:14  Show Profile  Reply with Quote
Please have a look at the post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=150223

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 04/18/2013 :  02:36:49  Show Profile  Reply with Quote
you can give field like that inside PIVOT

you need to use dynamic sql in PIVOT if you want values to be taken from a field.

http://beyondrelational.com/modules/2/blogs/70/posts/10840/dynamic-pivot-in-sql-server-2005.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000