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 |
|
richardsadler
Starting Member
1 Post |
Posted - 2005-03-07 : 17:57:19
|
| I have written a script to keep a track of diskspace on all our servers.The script writes disk stats to table called freespace with the following columnsComputer,Drive,Disksize,Freespace,Percentage,TimestampEach server writes an entry every 10 minutes.I need to get a web page that displays the latest data for each server partition being monitored.select Computer,drive,max(timestamp) from freespace group by computer,drive order by computerGives me all the servers, their partitions and the time of the last entry. BUt I want it to report back the above and some extra columns (Computer,Drive,Disksize,Freespace,Percentage,timestamp)Any Ideas how you would do that?I have been looking through the help and on the internet but cannot find anything.PS using MSSQL 2000Thanks,Richard. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-03-07 : 19:20:05
|
| select *from freespace fwhere timestamp = (select max(f2.timestamp) from freespace f2 where f2.computer = f.computer and f2.drive = f.drive)select f.*from freespace fjoin (select computer,drive, timestamp = max(timestamp) from freespace group by computer,drive) f2on f2.timestamp = f.timestampand f2.computer = f.computer and f2.drive = f.drive==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|