AZdesertdog
IS-IT--Management
Weekly we run a housekeeping script that detaches the dbase, deletes the transaction log and then re-attaches and have never had a problem.
Script is:
---------------------------------------------------------
EXEC sp_detach_db @dbname = 'rmprod'
go
exec xp_cmdshell 'erase d:\mssql2k\mssql\Data\RMProd_Log.LDF'
go
// delete the log file then run the next command
// This error on the attach is ok because I'm letting it //create a new log:
-- Device activation error. The physical file name 'D:\MSSQL2K\MSSQL\data\RMProd_Log.LDF' may be incorrect.
EXEC sp_attach_single_file_db @dbname = 'RMProd',
@physname = 'd:\mssql2k\mssql\Data\RMProd_Data.MDF'
go
----------------------------------------------------------
Today for some reason we're Getting this error on the attach:
-------------------------------------------------------
Server: Msg 1813, Level 16, State 2, Line 1
Could not open new database 'RMProd'. CREATE DATABASE is aborted.
Device activation error. The physical file name 'D:\MSSQL2K\MSSQL\data\RMProd_Log.LDF' may be incorrect.
Any ideas would be helpful! Thanks.
Script is:
---------------------------------------------------------
EXEC sp_detach_db @dbname = 'rmprod'
go
exec xp_cmdshell 'erase d:\mssql2k\mssql\Data\RMProd_Log.LDF'
go
// delete the log file then run the next command
// This error on the attach is ok because I'm letting it //create a new log:
-- Device activation error. The physical file name 'D:\MSSQL2K\MSSQL\data\RMProd_Log.LDF' may be incorrect.
EXEC sp_attach_single_file_db @dbname = 'RMProd',
@physname = 'd:\mssql2k\mssql\Data\RMProd_Data.MDF'
go
----------------------------------------------------------
Today for some reason we're Getting this error on the attach:
-------------------------------------------------------
Server: Msg 1813, Level 16, State 2, Line 1
Could not open new database 'RMProd'. CREATE DATABASE is aborted.
Device activation error. The physical file name 'D:\MSSQL2K\MSSQL\data\RMProd_Log.LDF' may be incorrect.
Any ideas would be helpful! Thanks.