Good Article that gave me some ideas. Here is an SP I created after reading the article that combines it all in 1 place, plus additions that you can put in the master DB on all SQL Servers (7-2005).
ALTER PROCEDURE dbo.sp_server_statistics
/*
(
@parameter1 datatype = default value,
@parameter2 datatype OUTPUT
)
*/
AS
/* Jack D. Corbett
**
** Returns basic server statistics
**
** Example
** ----------
** Exec master.dbo.sp_server_statistics
**
** History
** ----------
** 03-12-2007 Created
**
*/
SET NOCOUNT ON
Create Table #drive_stats
(
drive_letter varchar(10),
free_space Decimal(20, 2)
)
Create Table #sql_version
(
[index] int,
[name] varchar(100),
internal_value Int,
character_value varchar(200)
)
Create Table #stats
(
stat_skey Int Identity (1,1),
variable varchar(25),
value varchar(50)
)
Insert Into #drive_stats
Exec master..xp_fixeddrives
Insert Into #sql_version
Exec master..xp_msver
Insert Into #stats
(
variable,
value
)
SELECT
'Last Start Time',
login_time
FROM
master..sysprocesses
WHERE
spid = 1
Insert Into #stats
(
variable,
value
)
SELECT
'Uptime',
CONVERT(CHAR(25), DATEDIFF(DAY, login_time, GETDATE())) as 'Uptime'
FROM
master..sysprocesses
WHERE
spid = 1
Insert Into #stats
(
variable,
value
)
Select
'MB Free Space on ' + drive_letter,
free_space
From
#drive_stats
Insert Into #stats
(
variable,
value
)
Select
Case
When [name] = 'ProductVersion' then 'SQL Server Version'
When [name] = 'WindowsVersion' then 'Windows Version'
When [name] = 'ProcessorCount' then 'Processors'
When [name] = 'PhysicalMemory' then 'MB RAM'
Else [name]
End,
character_value
From
#sql_version
Where
[name] in ('ProductVersion', 'WindowsVersion', 'ProcessorCount', 'PhysicalMemory')
Order By
[index]
Select
*
From
#stats
ORder By
stat_skey
RETURN
Also, the SQLH2 tool that microsoft provided awhile ago provides some of this functionality and there are some RS reports you can download that report on the data collected by SQLH2.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question