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

sqlserver的日常检查脚本归结

 2012-02-15 12:23:49 来源:WEB开发网   
核心提示:print @@versiongoprint ' 'print ' 'select ca

print @@version


go




print '                                                   '


print '                                                   '


select cast(serverproperty('productversion') as varchar(30)) as 产品版本号,


cast(serverproperty('productlevel') as varchar(30)) as sp_level,


cast(serverproperty('edition') as varchar(30)) as 版本


go


print '                                                   '


print '                                                   '




print 'SQLSERVER max user connect         '


print '                                   '


print @@max_connections


go


print '*********************************'




print '                             '


print '                             '


print '                             '


print '----------------------------'


print '2.查看服务器有哪些数据库'


print '----------------------------'


print '*********************************'


print '                           '


SELECT 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,


上一页  7 8 9 10 11 12 13 14 15 16 17  下一页

Tags:sql server 脚本

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