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.
| Author |
Topic |
|
PHUser
Starting Member
11 Posts |
Posted - 2010-05-13 : 12:38:25
|
| Person Table ID Name 1 ABC Phone TableID Ph1 1111111 222222Result should look like this,1 ABC 111111 222222How can this be acheived? Can we use Pivot? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-13 : 12:41:55
|
| you can. but will there be always two phone numbers?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
PHUser
Starting Member
11 Posts |
Posted - 2010-05-13 : 12:45:15
|
No number of ph numbers varies.quote: Originally posted by visakh16 you can. but will there be always two phone numbers?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
PHUser
Starting Member
11 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-13 : 12:50:39
|
| no way without dynamic sql if you dont know number of values that can come in advance------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
PHUser
Starting Member
11 Posts |
Posted - 2010-05-13 : 12:52:28
|
Like i mentioned it doesn't have to use pivot. can we use a subquery?quote: Originally posted by visakh16 no way without dynamic sql if you dont know number of values that can come in advance------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-13 : 12:54:16
|
| nope. even then how will determine how many values to be crosstabbed? so it has to happen dynamically------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-14 : 03:02:43
|
quote: Originally posted by PHUser Like i mentioned it doesn't have to use pivot. can we use a subquery?quote: Originally posted by visakh16 no way without dynamic sql if you dont know number of values that can come in advance------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Why are you not using a pivot?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|