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 2000 Forums
 Transact-SQL (2000)
 Dynamic Query

Author  Topic 

GMANAFIP
Starting Member

13 Posts

Posted - 2008-12-22 : 09:05:52
How do I get a dynamic result set horizontal and vertical? I need to query the database to pull out several users and their accounts they are responsible for. Do I use pivot tables? The table should look similar to this:

John Fred Sue
1 5 6
2 21 20
4 33 44

Any ideas?

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-22 : 09:10:51
yes you can pivot the data.
Vertical data is always "dynamic" by default if you do group by.

However you need to code for "dynamic" columns.
There are pleny of examples here at SQLTeam.



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

GMANAFIP
Starting Member

13 Posts

Posted - 2008-12-22 : 10:08:31
Where are the examples located?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-22 : 10:16:18
Type "dynamic pivot crosstab" in search text box.
Press Search.



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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-12-24 : 05:47:49
or
http://sqlblogcasts.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 -