获取数据库服务器的配置信息
需要先启用SQLSERVER的xp_cmdshell选项才可以通过执行系统命令的方式进行获取,启用方式:
sp_configure 'xp_cmdshell',1
reconfigure
go
需要获取的信息包括:
获取机器名:
SELECT SERVERPROPERTY('MachineName')
HSZM1603-0013
wmic csproduct get version –获取服务器型号
exec xp_cmdshell ‘wmic csproduct get version’
Version
ThinkPad X250
wmic os get Caption –获取操作系统名称
exec xp_cmdshell ‘wmic os get Caption’
Caption
Microsoft Windows 10 专业版
wmic os get OSArchitecture –获取操作系统架构类型
exec xp_cmdshell ‘wmic os get OSArchitecture’
OSArchitecture
64 位
wmic cpu get numberofcores –获取Windows CPU物理核数
exec xp_cmdshell ‘wmic cpu get numberofcores’
NumberOfCores
2
wmic cpu get numberoflogicalprocessors –获取Windows CPU逻辑核数
exec xp_cmdshell ‘wmic cpu getnumberoflogicalprocessors’
NumberOfLogicalProcessors
4
wmic cpu get name –获取Windows CPU名称
exec xp_cmdshell ‘wmic cpu get name’
Name
Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
wmic cpu get MaxClockSpeed –获取Window主频(MHz)
C:\>wmic cpu get Maxclockspeed
MaxClockSpeed
2295
[hr]
推荐阅读