- 02 Apr 2024
- 2 Minutes to read
- Print
- DarkLight
- PDF
The LDF file can not be created when attaching it to SQL Server and I also receive an error message
- Updated on 02 Apr 2024
- 2 Minutes to read
- Print
- DarkLight
- PDF
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:
Create a blank database with equal size and use the same name for the MDF file to the one you're trying to attach
Stop SQL server
Replace the blank database MDF file with your current database file
Start SQL server
Open Enterprise Manager
The database will be in a suspect state in Enterprise Manager
Open SQL Query Analyzer and connect to the master database.
Run the following scripts:
select dbid, name from sysdatabases
* note the pharos dbid
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.
reconfigure with override
Expected result:
The command(s) completed successfully.
update sysdatabases set status = 32768 where dbid = (pharos dbid)
Expected result:
(1 row(s) affected)
Stop SQL Server.
Start SQL Server.
Reconnect SQL Query Analyzer to run the following queries against the master database:
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.
update sysdatabases set status = 16 where dbid = (pharos dbid)
Expected result:
(1 row(s) affected)
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.
reconfigure with override
Expected result:
The command(s) completed successfully.
Go back to Enterprise Manager and confirm that the database is OK.
Make sure the SQLSERVERAGENT Service is running and set to Automatic to run the Pharos Database backup each night.
Restart Pharos services.