DBmirroring state change SQL job

  • Hi All,

    I have created the sql job refering to the microsoft article.

    http://technet.microsoft.com/en-us/library/cc966392.aspx#XSLTsection129121120120

    For the step: Record state change

    INSERT INTO dbo.[DB Mirroring State Changes] (

    [Event Time],

    [Event Description],

    [New State],

    [Database] )

    VALUES (

    $(WMI(StartTime)),

    '$(WMI(TextData))',

    $(WMI(State)),

    '$(WMI(DatabaseName))' )

    I am getting this error message and sql job is failing:

    Unable to start execution of step 2 (reason: The job step contains tokens. For SQL Server 2005 Service Pack 1 or later, you must use the appropriate ESCAPE_xxx macro to update job steps containing tokens before the job can run.). The step failed.

    Any help is appreciated. Thanks.

  • Please take a look at :-

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

  • Use the appropriate escape macro, if you dont need to escape any quote marks then the following will apply

    INSERT INTO dbo.[DB Mirroring State Changes] (

    [Event Time],

    [Event Description],

    [New State],

    [Database] )

    VALUES (

    $(ESCAPE_NONE(WMI(StartTime))),

    $(ESCAPE_NONE(WMI(TextData))),

    $(ESCAPE_NONE(WMI(State))),

    $(ESCAPE_NONE(WMI(DatabaseName))))

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

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • When i execute this statement i am getting the below error message:

    INSERT INTO dbo.[DB Mirroring State Changes] (

    [Event Time],

    [Event Description],

    [New State],

    [Database] )

    VALUES (

    $(ESCAPE_NONE(WMI(StartTime))),

    $(ESCAPE_NONE(WMI(TextData))),

    $(ESCAPE_NONE(WMI(State))),

    $(ESCAPE_NONE(WMI(DatabaseName))))

    Output:

    Msg 102, Level 15, State 1, Line 7

    Incorrect syntax near '('.

Viewing 4 posts - 1 through 3 (of 3 total)

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