WEB开发网
开发学院数据库MSSQL Server sqlserver的日常检查脚本归结 阅读

sqlserver的日常检查脚本归结

 2012-02-15 12:23:49 来源:WEB开发网   
核心提示:serverproperty ('Machinename') as 'Machine', serverproperty ('Instancename') as 'InstanceName',

serverproperty ('Machinename') as 'Machine',                      


serverproperty ('Instancename') as 'InstanceName',                      


(SELECT 'file_type' =                      


CASE                      


WHEN s.groupid <> 0 THEN 'data'                      


WHEN s.groupid = 0 THEN 'log'                      


END) AS 'fileType'                      


, d.dbid as 'DBID'                      


, d.name AS 'DBName'                      


, s.name AS 'LogicalFileName'                      


, s.filename AS 'PhysicalFileName'                      


, (s.size * 8 / 1024) AS 'FileSizeMB' -- file size in MB                      


,d.cmptlevel as 'CompatibilityLevel'                      


, DATABASEPROPERTYEX (d.name,'Recovery') as 'RecoveryModel'                      


, DATABASEPROPERTYEX (d.name,'Status') as 'DatabaseStatus' ,                    


(SELECT 'is_replication' =                      


CASE                      


WHEN d.category = 1 THEN 'Published'                      


WHEN d.category = 2 THEN 'subscribed'                      


WHEN d.category = 4 THEN 'Merge published'


WHEN d.category = 8 THEN 'merge subscribed'


Else 'NO replication'


 END) AS 'Is_replication',


 @Mirroring as 'MirroringState'


FROM                      


sysdatabases d INNER JOIN sysaltfiles s                      


ON                      


d.dbid=s.dbid                      


ORDER BY                      

上一页  5 6 7 8 9 10 11 12 13 14 15  下一页

Tags:sql server 脚本

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接