sql server database logging script

Our database inspection once a quarter, so often use the following script

 

- 1. Check the version information database
the SELECT @@ Version
--2. See all database names and sizes
Exec sp_helpdb
--3. Check your operating system of the machine where the database parameters
Exec master..xp_msver
--4. View the database startup parameters

. --5 view start time database
SELECT Convert (VARCHAR (30), login_time, 120)
from master..sysprocesses. 1 WHERE SPID =
--6 view the database server name.
SELECT 'the Name Server:' + LTRIM (@@ ServerName)
. --7 View database instance name
the SELECT 'instance:' + LTRIM (@@ SERVICENAME)
--8 database disk space it uses the information.
Exec sp_spaceused
- 9 log file size and use.
dbcc SQLPERF (LOGSPACE)
- 10. table disk space usage information


SELECT
@@ total_read [number of disk reads],
@@ total_write [number of disk writes],
@@ total_errors [number of disk write error],
getdate () [current time]
--12. acquires I / O operation

--13. See operation of CPU activity and
SELECT
@@ cpu_busy,
@@ TimeTicks [corresponding to the number of clock cycles per sec],
@@ cpu_busy * Cast (@@ TimeTicks a float AS) / 1000 [CPU operating time (seconds )],
@@ iDLE * Cast (@@ TimeTicks a float AS) / 1000 [the CPU idle time (sec)],
getdate () [current time]
--14. checks the lock-and-wait
Exec the sp_lock
--15. deadlock check

exec sp_who
exec sp_who2

--17 Information active users and processes
exec sp_who 'active'

 


--20. View all database user belongs to role information
exec sp_helpsrvrolemember

--21. View link server
exec sp_helplinkedsrvlogin

 

 

 

--25.查询文件组和文件
select
df.[name],df.physical_name,df.[size],df.growth,
f.[name][filegroup],f.is_default
from sys.database_files df join sys.filegroups f
on df.data_space_id = f.data_space_id

 


--28. View the actual SQL Server memory footprint
select * from sysperfinfo where counter_name like ' % Memory%'


--29. Log space to display information about all database
dbcc sqlperf (logspace)

select *,CAST(cntr_value/1024.0 as decimal(20,1)) MemoryMB
from master.sys.sysperfinfo
where counter_name='Total Server Memory (KB)'

Guess you like

Origin www.cnblogs.com/mlwork/p/11532925.html