sqlserver的日常检查脚本归结
2012-02-15 12:23:49 来源:WEB开发网print ' '
print '-------------------------------------------------------'
print '20. 查看所有数据库大小、恢复模式等信息'
print '-------------------------------------------------------'
SELECT substring (DatabaseName,0,12) as DatabaseName,DataSize,LogSize,DataSize+LogSize AS TotalSize, Collation, RecoveryType,AutoClose,AutoShrink
FROM
(SELECT DBID,
CASE Sum(size*8/1024)
WHEN 0 THEN 1
ELSE Sum(size*8/1024)
END AS DataSize
FROM master..sysaltfiles
WHERE GroupID <> 0
GROUP BY DBID) q1
INNER JOIN
(SELECT DBID,
CASE Sum(size*8/1024)
WHEN 0 THEN 1
ELSE Sum(size*8/1024)
END AS LogSize
FROM master..sysaltfiles
WHERE GroupID = 0
GROUP BY DBID) q2
ON q1.DBID = q2.DBID
INNER JOIN
(SELECT DBID, [name] AS DatabaseName,
CONVERT(varchar(100),DATABASEPROPERTYEX([Name], 'Collation')) AS Collation,
CONVERT(varchar(100),DATABASEPROPERTYEX([Name], 'Recovery')) AS RecoveryType,
CASE CONVERT(varchar(10),DATABASEPROPERTYEX([Name], 'IsAutoClose'))
WHEN 0 THEN '-'
WHEN 1 THEN 'Yes'
END AS AutoClose,
CASE CONVERT(varchar(10),DATABASEPROPERTYEX([Name], 'IsAutoShrink'))
WHEN 0 THEN '-'
WHEN 1 THEN 'Yes'
END AS AutoShrink
FROM master.dbo.sysdatabases) q3
ON q1.DBID = q3.dbid
ORDER BY DatabaseName
print ' '
print ' '
print '-------------------------------------------------------'
print '21. 查看数据库群集信息'
print '-------------------------------------------------------'
PRINT ' **** Cluster Information ****'
PRINT ' '
PRINT ' The following is information on the cluster you are connected'
PRINT ' '
PRINT '... Name of all nodes used and are part of this failover cluster'
SELECT * FROM sys.dm_os_cluster_nodes
PRINT ' '
PRINT '... Node which is the active '
SELECT SERVERPROPERTY('ComputerNamePhysicalNetBIOS')
PRINT ' '
PRINT '... Drive letters that are part of the resourse group which contain the data and log files'
SELECT * FROM sys.dm_io_cluster_shared_drives
go
print ' '
- ››sql server自动生成批量执行SQL脚本的批处理
- ››sql server 2008亿万数据性能优化
- ››SQL Server 2008清空数据库日志方法
- ››sqlserver安装和简单的使用
- ››SQL Sever 2008 R2 数据库管理
- ››SQL SERVER无法安装成功,sqlstp.log文件提示[未发...
- ››Sql Server中通过父记录查找出所有关联的子记录
- ››SqlServer触发器、存储过程和函数
- ››SQL Server 中的事务(含义,属性,管理)
- ››Sqlite数据库插入和读取图片数据
- ››Sql server 2005拒绝了对对象 'xx表' (数...
- ››Sql server 2005拒绝了对对象 'xx表' (数...
更多精彩
赞助商链接