Query WMI from within SQL Server

  • Hi there,

    I am hoping to be able to query WMI from within SQL Server. Presently I'm running VBscripts via Task Scheduler & then a bulk import from the resulting output file into a table, however being able to somehow directly query WMI would be great.

    Does anybody have any advice or information on this? So far I have not been able to find anything, leading me to think it is not possible, short of writing a stored procedure that creates and executes a VBscript, then reads into a temp table and return the select.

    thanks, Mark

  • This should be a good starting place. There are examples throughout the sublinks in the link provided.

    http://msdn.microsoft.com/en-us/library/ms180606(SQL.90).aspx

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • If I understand the link correctly (I'd found it a few times googling this issue), this is about using WMI to get information on SQL server, or creating SQL Agent alerts based on WMI events.

    What I'm trying to do is to execute WQL directly from within SQL server. I didn't see that in these articles (I could be wrong though).

    For example:

    insert into tblErrorLog

    Select * from Win32_NTLogEvent

    Where Type <> 'Information' and

    (Logfile = 'System' or Logfile='Application')

  • Have you considered exploring powershell and SMO to do this from the SQL Server perspective?

    http://msdn.microsoft.com/en-us/library/cc281947.aspx

    http://www.simple-talk.com/sql/database-administration/why-this-sql-server-dba-is-learning-powershell/

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I hadn't actually, however it might be worth a look. Thanks for the pointer!

    cheers, Mark

  • You're welcome.

    Otherwise, I'm drawing a blank on any other method than what you described.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • An alternative is using SSIS. It contains components to work with WMI.

    Peter

  • Hope this helps: Article : SQL WMI Provider

    This article explains SQL WMI overview and how to use it from Powershell, VBScript, C#, C++, and SMO WMI.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply