Renaming database causing dbid problems

  • Hi, We are converting a very large application with multiple databases from SQL6.5 to SQL2000. We have a 2 copies of one database - one "Online", one "Offline". The "OnLine" database is accessed by web. The "OffLine" database receives updates. As part of nightly batch cycle, we (previously, in 6.5) turned the "Offline" database into the "Online" database and did a dump and load to sync up the two databases.

    One other piece of info - the databases are accessed by stored procedures from another 'driver' database that always knows which is "On" or "Off" and calls stored procs accordingly. The stored procedures in this driver database have logic like:

    If db1 is 'online'

    exec db1.dbo.myproc

    else

    exec db2.dbo.myproc

    With SQL2000, this no longer works. The stored procs in the 'driver' database fail on existence checking when we are in the middle of our load process.

    We thought we could do something with sp_renamedb, but this appears to cause problems with the underlying dbid. We are getting the following error:

    Server: Msg 913, Level 16, State 8, Procedure TestOfDBRef, Line 8

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

    ---Does anyone have any ideas how to solve our problem? Is it possible to control the dbID?

    Thanks for any help you can give 🙂

  • I dont think (but have not confirmed) that doing a restore changes the dbid. The error looks more like recovery hasnt completed - are you sure the db is online when you're running the code?

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

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

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