WMI alerting error

After installing SQL Server 2005, I tried to create a WMI alert by doing the following:

USE [msdb]
GO
EXEC msdb.dbo.sp_add_alert @name=N'Database Created',
@enabled=1,
@delay_between_responses=0,
@include_event_description_in=0,
@wmi_namespace=N'\\.\root\Microsoft\SqlServer\ServerEvents\MSSQLSERVER',

@wmi_query=N'SELECT * FROM CREATE_DATABASE',
@job_id=N'00000000-0000-0000-0000-000000000000'
GO

This produces:

"The @wmi_query could not be executed in the @wmi_namespace provided.
Verify that an event class selected in the query exists in the
namespace and that the query has the correct syntax."

Now, I have done the install many times on a VM box and believe to have tracked it down to moving the msdb database. The alerts can be created, but after the move, I get the above error.

To move the db, I used sp_detach_db after adding the -T3608 trace flag. I then moved the .mdf and .ldf files, then removed the trace flag and reattached msdb.

Any ideas as to what the problem is



Answer this question

WMI alerting error

  • RWeigelt

    Has anyone figured out how to fix this problem I also receive the same error and I did not move msdb, it still sits in the default location on c:\, all other databases are off the system drive. We are somewhere along the chain of SP2 updates, I believe SP2a before hotfixes.

    Any help would be greatly appreciated.


  • Ori234454

    I am trying to setup the alerts according the article published on http://www.microsoft.com/technet/prodtechnol/sql/2005/mirroringevents.mspx in the chapter "Script Sample - Create Alerts for All Database Mirroring Events"

    I ran the script on the priciplal server running SQL 2005 SP2 (9.00.3159.00)

    I am grtting the errors below:

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Thanks,

    Vlad


  • Ruben S Salazar

    Is there any way to address the problem without having to re-install SQL Server
  • Surfertje

    In general, sp_detach_db and sp_attach_db is NOT recommended way to move a system database.

    Our test team validated this scenario by using the recommended way to move database (see topic “Moving Database Files” in BOL) and it works fine.

    There was no problem with sp_add_alert once msdb was moved.

    The steps followed

    1. determine the logical name of the database and current location of physical files

    SELECT name AS [logical name], physical_name AS [location]

    FROM sys.master_files

    WHERE database_id = DB_ID('msdb')

    2. change the location of each file from the step 1

    --ALTER DATABASE msdb

    --MODIFY FILE (NAME = <logical_name>, FILENAME = <new_location\file_name>)

    USE master;

    GO

    ALTER DATABASE msdb

    MODIFY FILE (NAME = MSDBData, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\msdbdata.mdf');

    GO

    ALTER DATABASE msdb

    MODIFY FILE (NAME = MSDBLog, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\msdblog.ldf');

    GO

    3. stop SQL Server

    4. move each file from the step 1 to the new location

    5. start SQL Server



  • sewe

    This looks like a bug. Please file bug for us to track this issue at product feedback center

    http://lab.msdn.microsoft.com/productfeedback/

    Thanks



  • prigun

    I'm having the same problem described in original post with creating a WMI-based alert. I too had moved my msdb database via detach/attach. I moved msdb back to original location via the "alter database modify file..." commands. No luck. I re-installed sql server 2005. I moved my msdb database using the "alter database modify file...." method to where I want it to be, WMI-alert won't create. I moved it back. WMI-alert won't create.
  • Justin Niemetscheck

    I am too having this problem, i have not moved my MSDB or any other DB's. This is a Build 3042 SP2 box, has anyone seen a work around or hotfix

    Thanks,



  • jkuster

    I too am getting this error. We are running sp1.

    TITLE: Microsoft SQL Server Management Studio

    ------------------------------

    Cannot create new alert. (SqlManagerUI)

    ------------------------------

    ADDITIONAL INFORMATION:

    Create failed for Alert 'test'. (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Alert&LinkId=20476

    ------------------------------

    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

    ------------------------------

    SQLServerAgent Error: WMI error: 0x80041010.

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax. (Microsoft SQL Server, Error: 22022)

    For help, click: http://go.microsoft.com/fwlink ProdName=Microsoft+SQL+Server&ProdVer=09.00.2153&EvtSrc=MSSQLServer&EvtID=22022&LinkId=20476

    ------------------------------

    BUTTONS:

    OK

    ------------------------------


  • vccool

    If you want to move the sys.databases then above suggestion to stop and start SQL services, not to reinstall the whole components.

    I would like to know what was your problem



  • Tim Haynes

    I tried the cumulative hotfixes for SP2 in an attempt to fix the issue and had no luck. I can get this same WMI alert to work on SQL 2005 databases prior to SP2.
  • santosh k singh

    Hello, everybody!
    For a moment, I thought SQLDan had solved my problem, because I also was trying to create alerts on a DB in mirroring session. Infortunately, after failover the DB, the problem keeps happening.
    I'm working with two server: A and B. The server A is the principal server, server B is the mirror one. Both have the same softwares and configurations. On server A, I was able to create all the alerts suggested in BOL. My problem is on server B, where I can’t create the alerts with WMI. As i said above, I forced a failover to make my DBs on server B the principal DBs and tried to create the alerts, but it fails.
    Ah, one more think. We installed SQL Server on a drive "S", due to our storage structure. The MSDB (mdf and lddf) is in S:\Microsoft SQL Server\MSSQL.1\MSSQL\DATA.
    Any thoughts, ideas, magics or miracles to help us all
    Thanks.


  • anayconsultancy

    I found out what was causing my error. I am in the process of deploying DB mirroring, i was running the sp_add_alert against the syncronising DB on the mirror server that is in a recovery mode.(doh)..so the alert could not be verified and errored that the namespace could be wrong.

    I also did think it maybe a security issue, using WBEMTest tool to check the security will help..

  • WillRogers

    I got the same error on an Instance that I restored the MSDB database on.

    So I tested this by creating a WMI Alert on a fresh install of SQL Server 2005 and it was created successfully.

    So I delete the alert, backed up the MSDB and restored it.

    Now when I try to create a WMI alerts, I get this error message
    "The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax."


    Conclusion:
    It seems if you restore MSDB it will break WMI Alerts.

  • Brenden

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.

    Msg 22022, Level 16, State 1, Line 0

    SQLServerAgent Error: WMI error: 0x80041013.

    Msg 14511, Level 16, State 1, Procedure sp_verify_alert, Line 300

    The @wmi_query could not be executed in the @wmi_namespace provided. Verify that an event class selected in the query exists in the namespace and that the query has the correct syntax.


  • WMI alerting error