Error - Database may not be activated

  • As part of a maintenance routine I've scheduled some DBCC commands to run via a stored procedure. Since dropping a database the job is now failing with the error

    Could not find database ID 7. Database may not be activated yet or may be in transition.

    I've dropped and recreated the stored procedure and the job but still get this error. I've also tried calling the SP with the recompile option but no luck. The strange thing is that if I call the SP direct from query analyzer it works fine.

    Getting a bit confused - any help appreciated

    cheers

  • quote:


    As part of a maintenance routine I've scheduled some DBCC commands to run via a stored procedure. Since dropping a database the job is now failing with the error

    Could not find database ID 7. Database may not be activated yet or may be in transition.

    I've dropped and recreated the stored procedure and the job but still get this error. I've also tried calling the SP with the recompile option but no luck. The strange thing is that if I call the SP direct from query analyzer it works fine.

    Getting a bit confused - any help appreciated


    have you verified the entry in master.sysdatabases for the db in question? something like

    SELECT * FROM master.sysdatabases ?

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • What if you script the job, deleted it and recreate it with the script. Should refresh all possible references

  • Verified that the ID 7 does NOT exist in sysdatabases.

    I have scripts for the sp and the job and have recreated them more times than I care to remember but still get this error. I can't understand where it's picking this up from.

    The sp is running a dbcc sqlperf(logspace) and a dbcc showfilestats to return size information of all the databases.

    Thanks

  • quote:


    Verified that the ID 7 does NOT exist in sysdatabases.

    I have scripts for the sp and the job and have recreated them more times than I care to remember but still get this error. I can't understand where it's picking this up from.

    The sp is running a dbcc sqlperf(logspace) and a dbcc showfilestats to return size information of all the databases.


    so you have a db with the same name as the dropped one, but different dbid?

    Could you post your code?

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Are you maintaining any intermediate table with DB Ids? If yes, then, try dropping and recreating it. Then it Should work.

    If possible, try and post u'r code.

  • Well I fixed it. Created a blank database which was given the ID of 7 and then dropped it. The job and sp run fine now. I can only think something screwy happened when the original ID 7 database was dropped.

    Thanks for your time.

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

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