IndexOptimize Script

  • Hi,

    Has anyone run the latest Ola Hallengren's IndexOptimize script (September 25)?

    I'm not sure why but when I run the job, I get the error "Executed as user: NT SERVICE\SQLSERVERAGENT. Incorrect syntax near 'E'. [SQLSTATE 42000] (Error 102). The step failed."

    sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d DBA_Utils -Q "EXECUTE [dbo].[IndexOptimize] @databases = 'USER_DATABASES', @UpdateStatistics = 'ALL', @StatisticsSample = 100, @LogToTable = 'Y'" -b

    Is there anything blatantly wrong with this command?

    Thanks,

    Mike

    Mike Scalise, PMP
    https://www.michaelscalise.com

  • Mike Scalise (9/27/2016)


    Hi,

    Has anyone run the latest Ola Hallengren's IndexOptimize script (September 25)?

    I'm not sure why but when I run the job, I get the error "Executed as user: NT SERVICE\SQLSERVERAGENT. Incorrect syntax near 'E'. [SQLSTATE 42000] (Error 102). The step failed."

    sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d DBA_Utils -Q "EXECUTE [dbo].[IndexOptimize] @databases = 'USER_DATABASES', @UpdateStatistics = 'ALL', @StatisticsSample = 100, @LogToTable = 'Y'" -b

    Is there anything blatantly wrong with this command?

    Thanks,

    Mike

    Quick question, is the job step T-SQL or CmdExec? The former will produce this error.

    😎

  • Eirikur,

    The step is the "sqlcmd" line that I pasted above. I mean, it passes in T-SQL.

    Does that answer your question? Do you know how I would address this?

    Thanks,

    Mike

    Mike Scalise, PMP
    https://www.michaelscalise.com

  • If you open the job and select Steps on the left, what is the Type of the job step? It should be "Operating System (CmdExec).

    😎

  • Eirikur Eiriksson (9/27/2016)


    If you open the job and select Steps on the left, what is the Type of the job step? It should be "Operating System (CmdExec).

    😎

    I'm sorry, I didn't understand the question initially. I just checked the step type and you were right. It wasn't "Operating System (CmdExec)" which makes sense because this is a job I had created separately and I never change the type before using the command from the job Ola's scripts created. It's working now!

    All of my research pointed to a problem with the string itself (e.g., not enclosing objects with square brackets, etc.), but it was the job step type all along.

    Thanks so much Eirikur! You saved me a lot of time.

    Mike

    Mike Scalise, PMP
    https://www.michaelscalise.com

  • You are very welcome Mike and thanks for the feedback.

    😎

Viewing 6 posts - 1 through 5 (of 5 total)

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