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)
 pivot / crosstab

Author  Topic 

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-13 : 06:27:11
hello,
I am using the crosstab sp at :
http://www.sqlteam.com/item.asp?ItemID=2955
it works successfully, but I need to use the data to create a graph.

how can I run this sp and insert the data into a table.
bearing in mind the rows of the table increases wit hthe date... ?

EXECUTE crosstab 'SELECT servername, drive FROM Info
GROUP BY servername, drive ORDER BY Servername', 'max(utilisation)', 'date' , 'Info'


thank you,
Jamie

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-07-13 : 09:27:46
What tools are you using to create the graph?
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-13 : 10:11:36
Excel at present.

even so, is it possible to run this and insert the data into a table even though the tables fields increase by 1 everyday ?
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-14 : 05:22:38
hi,
is this possible ?
I'm thinking I could do this by seleting disctint dates then building table fields with those values, but how can I do this ?

eg, select distinct date from table give :

01/01/2004
02/01/2004
03/01/2004

then create table ( field1 = 01/01/2004, field2 = 02/01/2004 and so on )

every day a new date will be added.

thanks a lot for any help.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-07-14 : 08:44:44
jamie --

why are you trying to change the formatting of your results in SQL Server? Excel has pivotting built-in ! and it even has pivot table charts/graphs ready to go for you. just return the data in a normal row/column format into Excel (summarized by all of the dimensions you need to pivot by) and let Excel do the pivoting.

you are making things way more complicated than they need to be; I have found that about 80% of the time people create pivot tables in SQL Server (usually with looong SQL Statements or funky stored procedures w/ Dynamic SQL) they can do it easily at the presentation layer. This is definitely one of those cases.

Let SQL Server return the raw data summarized as needed, and let the presentation layer (in this case Excel) do the presentation. This also applies to date/numeric formatting as well.


- Jeff
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-14 : 10:03:03
thanks Jeff, think I'll go back to the drawing board and see if excel can solve my problems.
thanks for the advice.
Jamie
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-14 : 10:11:13
jeff, can you use pivot tables ?
I have a table with 4 fields, date, servername, serverdrive and disk space.

I want a line graph to show disk space over time for each drive on each server.
its the each drive on each server part I am having problems with.
any suggestions ?
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-07-14 : 11:15:14
just put some data into Excel. then choose Data-->Pivot Table and Pivot Report.

say you want to use an Excel range

highlight your table in Excel.

Then you drag and drop the various fields to make the chart look the way you like.

you may need to go to an Excel forum for more info.

- Jeff
Go to Top of Page
   

- Advertisement -