Error: 7987

  • after an electrical problem, my database MyDB showed it

    'SUSPECTED',

    then I detach de DB and when I attach it again this message

    Server: Msg 7987, Level 22, State 1, Line 1

    A possible database consistency problem has been detected on database 'MyDB'.  DBCC CHECKDB and DBCC CHECKCATALOG should be run on database 'MYDB'.

    I run this line too

     

    EXEC sp_attach_single_file_db @dbname = N'MyDB',

       @physname  = N'D:\MSSQL\MSSQL\Data\N'MyDB'.mdf'

     

     

    Server: Msg 1813, Level 16, State 2, Line 1

    Could not open new database 'N'MyDB''. CREATE DATABASE is aborted.

    Device activation error. The physical file name 'D:\MSSQL\MSSQL\Data\N'MyDB'.ldf' may be incorrect.

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

     

    EXEC sp_attach_db @dbname = N'MyDB',

       @filename1  = N'D:\MSSQL\MSSQL\Data\MyDB.mdf',

       @filename2 = N'D:\MSSQL\MSSQL\Data\MyDB.ldf'

     

    Server: Msg 7987, Level 22, State 1, Line 1

    A possible database consistency problem has been detected on database 'MyDB'.  DBCC CHECKDB and DBCC CHECKCATALOG should be run on database MyDB'.

     

    -- Connection Broken

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

    SP4 is installed

     

    Can you help me?

  •  

    If I understand correctly**, you run:

    EXEC sp_attach_db @dbname = N'MyDB',

       @filename1  = N'D:\MSSQL\MSSQL\Data\MyDB.mdf',

       @filename2 = N'D:\MSSQL\MSSQL\Data\MyDB.ldf'

    and end up with a database marked SUSPECT and the following message:

    Server: Msg 7987, Level 22, State 1, Line 1

    A possible database consistency problem has been detected on database 'MyDB'.  DBCC CHECKDB and DBCC CHECKCATALOG should be run on database MyDB'.

    But your database IS attached (otherwise it would not be marked suspect). Follow the advice and run:

    DBCC CHECKDB(MyDB)

    it is a dabase consistency check and it can fix problems. Look at the command in the BOL. If you are not familiar with it and want to be sure everything is fixed, run it a second time like this:

    DBCC CHECKDB(MyDB) WITH NO_INFOMSGS

    With this option, you will be spared non critical information. If there is no output, you are probably clear.

    Dido with CHECKCATALOG.

    ** if the db can't be attached at all , you will have to restore from a backup.

    hope it helps

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

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