SQL query against hardware. Possible?
I need to query the Total Physica开发者_如何学Pythonl Memory, Available Physical Memory and Total Commit Charge of the server. Basically values circled in the picture. Is it possible using SQL Server 2005?
alt text http://www.angryhacker.com/toys/task.png
You can try using the sys.dm_os_sys_info table. Wich returns a miscellaneous set of useful information about the computer, and about the resources available to and consumed by SQL Server.
USE [master];
SELECT * FROM sys.dm_os_sys_info
Bye.
It's not entirely clear what you're asking. You can use a subset of SQL called WQL to get information from WMI, and I'm pretty sure all the data you're asking for is available via WMI, so you should be able to get it all via a SQL query. That SQL query won't be talking to the actual SQL server at the time though, it'll be talking to the WMI provider via the WQL adapter.
I'm not sure about the entire box, but you can use DBCC MemoryStatus to get the consumption of SQL Server itself.
Here's an article about it.
I don't think you really mean SQL as in Database information, it looks to me like you're trying to query the operating system for performance information. Is that right?
You'd need to perform WMI queries for that, instead of SQL queries (which are designed for database access)
Here's an example for getting memory information:
http://www.computerperformance.co.uk/vbscript/wmi_memory.htm#Scenario_-_When_to_use_this_WMI_Memory_Script_
The web site included in the link above has all kinds of samples, and I think you'd be able to get to what you want by researching there.
精彩评论