using Tsql statements in Maintenance Plan

  • I am trying to setup a maintenance plan, using t-sql statements I call a stored procedure but I get following error.

    failed with the following error: "Could not find stored procedure 'xxxxxxxxxxxx'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    it will run just fine if I create a sql job, but it won't work when I set it up via maintenance plan.Any ideas?

    thanks

  • Did you set the database context correctly?

  • would you please elaborate. What database context you referring to?

  • In your SQL Statement, did you specify the database where the stored procedure is located?

    If not, it will execute in the context to your default database, which is usually master.

  • Thanks much for your reply. This is what I use :

    use [databasename]

    Go

    EXEC dbo.ap_RebuildIndexes @maxfrag=15.0, @maxdensity=90.0

    , @databasename='databasename'

    in sql jobs I don't need first two lines because I can choose the database from drop down box.

    Thanks

    Foad

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

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