The LDF file can not be created when attaching it to SQL Server and I also receive an error message
  • 02 Apr 2024
  • 2 Minutes to read
  • Dark
    Light
  • PDF

The LDF file can not be created when attaching it to SQL Server and I also receive an error message

  • Dark
    Light
  • PDF

Article summary

I currently have the client's MDF file but I am unable to attach it to the SQL server

Error:

File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL\data\Settings_Log.LDF" may be incorrect.

The log cannot be rebuilt because the database was not cleanly shut down.


**** This process will only work with SQL 2000 - not SQL 2005, because of the security setting on updating a particular master table *****

Updates to system catalogs are not allowed - a big subject and nothing but opening the door to trouble by allowing direct updates or modifications to system tables in SQL Server 2005. Microsoft has been discouraging updates to system tables even though the provision has been enabled. Since SQL Server 2005, it has been totally removed.

So when you attempt to update the system catalogs the user will get the error:

Msg 259, Level 16, State 1, Line 1

Ad hoc updates to system catalogs are not allowed.

Steps for SQL 2000:

  1. Create a blank database with equal size and use the same name for the MDF file to the one you're trying to attach

  2. Stop SQL server

  3. Replace the blank database MDF file with your current database file

  4. Start SQL server

  5. Open Enterprise Manager

  6. The database will be in a suspect state in Enterprise Manager

  7. Open SQL Query Analyzer and connect to the master database.

  8. Run the following scripts:

    1. select dbid, name from sysdatabases

      * note the pharos dbid

    2. sp_configure 'allow', 1

      Expected result:

      DBCC execution completed. If DBCC printed error messages, contact your system administrator. Configuration option "allow updates' changed from 1 to 1. Run the RECONFIGURE statement to install.

    3. reconfigure with override

      Expected result:

      The command(s) completed successfully.

    4. update sysdatabases set status = 32768 where dbid = (pharos dbid)

      Expected result:

      (1 row(s) affected)

  9. Stop SQL Server.

  10. Start SQL Server.

  11. Reconnect SQL Query Analyzer to run the following queries against the master database:

    1. dbcc rebuild_log ('pharos', 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\pharos.ldf')

      * path and file name should match the location and name of the old log file that was deleted.

      Expected result:

      Warning: The log for database 'pharos' has been rebuilt. Transactional consistency has been lost. DBCC CHECKDB should be run to validate physical consistency. Database options will have to be reset, and extra log files may need to be deleted.

      DBCC execution completed. If DBCC printed error messages, contact your system administrator.

    2. update sysdatabases set status = 16 where dbid = (pharos dbid)

      Expected result:

      (1 row(s) affected)

    3. sp_configure 'allow', 0

      Expected result:

      DBCC execution completed. If DBCC printed error messages, contact your system administrator. Configuration option 'allow updates' changed from 1 to 0. Run the RECONFIGURE statement to install.

    4. reconfigure with override

      Expected result:

      The command(s) completed successfully.

  12. Go back to Enterprise Manager and confirm that the database is OK.

  13. Make sure the SQLSERVERAGENT Service is running and set to Automatic to run the Pharos Database backup each night.

  14. Restart Pharos services.


Was this article helpful?


Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.