Re: Detached database can't be attached back

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 01/14/05


Date: Fri, 14 Jan 2005 08:39:39 +0100

Are you saying that you deleted one of the log files, and then copied the second log file to the
first log files name and location? If so, you probably need to go the restore route, open a case or
try the last resort posted by Andrew. If not, well, your options are the same...

-- 
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Percy Cabello" <Percy Cabello@discussions.microsoft.com> wrote in message 
news:952BA145-8E36-43FC-9010-BE2B0E5E14EA@microsoft.com...
> Hi
>
> I dettached a database in order to move it to another drive where I have
> more space. Original database had 2 datafiles and 2 log files. A data file
> and a log file in c:\program files\microsoft sqlserver\mssql\data, called
> crn_data.mdf and crn_log.ldf respectively. The other datafile and log file in
> d:\mssql\data called crn_data2_data.ndf and crn_log2_log.ldf respectively.
> So, I detached the database using EM: disconnected all users and put the DB
> (crn) on DBO-only mode, then successfully dettached. The I deleted the ldf in
> the C drive. Then moved the C: mdf datafile to d:\mssql\data together with
> the other data file and the second log file.
>
> When first tried to attach dastabase through EM it failed to verify all 4
> files in the attach dialog. So I copied second log file to original location
> with the same old name trying to fool EM. Tried again and it passes
> validation and the OK button is enabled, but the process fails: Error 5171
> file c:\program files\microsoft sql server\data\crn_log.ldf is not a primary
> database file. Could not open new darabase 'crn'. CREATE DATABASE is aborted.
> Device activation errror, The physical name 'c:\program files\microsoft sql
> server\data\crn_log.ldf '  may be incorrect.
>
> I've also tried:
> sp_attach_db 'crn', 'd:\mssql\data\crn_Data.mdf',
> 'd:\mssql\data\crn_Data2_data.ndf'
>
> result:
> Server: Msg 5171, Level 16, State 2, Line 1
> C:\Program Files\Microsoft SQL Server\MSSQL\data\crn_Log.LDF is not a
> primary database file.
> Server: Msg 1813, Level 16, State 1, Line 1
> Could not open new database 'crn'. CREATE DATABASE is aborted.
> Device activation error. The physical file name 'C:\Program Files\Microsoft
> SQL Server\MSSQL\data\crn_Log.LDF' may be incorrect.
>
> tried: sp_attach_single_file_db 'crn', 'd:\mssql\data\crn_Data.mdf'
>
> result: Server: Msg 5171, Level 16, State 2, Line 1
> C:\Program Files\Microsoft SQL Server\MSSQL\data\crn_Log.LDF is not a
> primary database file.
> Server: Msg 1813, Level 16, State 1, Line 1
> Could not open new database 'crn'. CREATE DATABASE is aborted.
> Device activation error. The physical file name 'C:\Program Files\Microsoft
> SQL Server\MSSQL\data\crn_Log.LDF' may be incorrect.
>
> tried:sp_attach_db 'crn', 'd:\mssql\data\crn_Data.mdf',
> 'd:\mssql\data\crn_Data2_data.ndf', 'd:\mssql\data\crn_log.ldf',
> 'd:\mssql\data\crn_Log2_log.ldf'
>
> result: sp_attach_db 'crn', 'd:\mssql\data\crn_Data.mdf',
> 'd:\mssql\data\crn_Data2_data.ndf', 'd:\mssql\data\crn_log.ldf',
> 'd:\mssql\data\crn_Log2_log.ldf'
>
> I've used the attach/detach process in the past with no problem at all.
> Could somebody provide some advice on what could be going on?
>
> Thanks in advance.
>
> Percy 


Relevant Pages

  • Re: Detached database cant be attached back
    ... Andrew J. Kelly SQL MVP ... Original database had 2 datafiles and 2 log files. ... The other datafile and log file ... Could not open new darabase 'crn'. ...
    (microsoft.public.sqlserver.server)
  • Re: How to manage the transaction log
    ... Just remember to backup the database before the BCP ... I am using the SQL Server 2005 Express. ... I set the Autogrowth of log file unrestricted. ...
    (microsoft.public.sqlserver.tools)
  • Re: PEAR DB - Useful?
    ... SQL, all I have to do is change the connect string and I can use it to ... work with more or less any database out there. ... PHP5's exceptions and stuff, ... debugging information in a log file. ...
    (comp.lang.php)
  • Re: How to manage the transaction log
    ... As I mentioned in my previous post, the issue is even if I set the log file ... am still new to SQL Server. ... I created the database with "Simple" Recover Model. ... Just remember to backup the database before the BCP ...
    (microsoft.public.sqlserver.tools)
  • Detached database cant be attached back
    ... Original database had 2 datafiles and 2 log files. ... The other datafile and log file in ... Could not open new darabase 'crn'. ... The physical name 'c:\program files\microsoft sql ...
    (microsoft.public.sqlserver.server)