Wednesday, March 21, 2012

Recovering a DB using sp_attach_db

Hi, All!
I'am trying to recover a database using sp_attach_db. I just have the .MDF
file. I tried this command, and receive this result:
EXEC sp_attach_db 'Contax', 'C:\Arquivos de programas\Microsoft SQL
Server\MSSQL\Data\Contax.mdf'
Server: Msg 1813, Level 16, State 2, Line 1
Could not open new database 'contax'. CREATE DATABASE is aborted.
Device activation error. The physical file name
'D:\Bancos\Logs\\contax_log.LDF' may be incorrect.
I don't have the LDF file, but I suppose that SQL Server would create a new
one. Besides, the physical path in the error message has two slashes (after
"Logs" directory), and I found it weird...
Could somebody help me?
Thanks a lot.
MarcosTry using sp_attach_single_file_db ... for the syntax look at BOL
Thanks
GYK
"Marcos Federicce" wrote:
> Hi, All!
> I'am trying to recover a database using sp_attach_db. I just have the .MDF
> file. I tried this command, and receive this result:
> EXEC sp_attach_db 'Contax', 'C:\Arquivos de programas\Microsoft SQL
> Server\MSSQL\Data\Contax.mdf'
> Server: Msg 1813, Level 16, State 2, Line 1
> Could not open new database 'contax'. CREATE DATABASE is aborted.
> Device activation error. The physical file name
> 'D:\Bancos\Logs\\contax_log.LDF' may be incorrect.
> I don't have the LDF file, but I suppose that SQL Server would create a new
> one. Besides, the physical path in the error message has two slashes (after
> "Logs" directory), and I found it weird...
> Could somebody help me?
> Thanks a lot.
> Marcos|||GYK,
I already tried sp_attach_single_file_db, but I got the same error message :)
Thanks anyway
Marcos
"GYK" wrote:
> Try using sp_attach_single_file_db ... for the syntax look at BOL
> Thanks
> GYK
> "Marcos Federicce" wrote:
> > Hi, All!
> >
> > I'am trying to recover a database using sp_attach_db. I just have the .MDF
> > file. I tried this command, and receive this result:
> >
> > EXEC sp_attach_db 'Contax', 'C:\Arquivos de programas\Microsoft SQL
> > Server\MSSQL\Data\Contax.mdf'
> >
> > Server: Msg 1813, Level 16, State 2, Line 1
> > Could not open new database 'contax'. CREATE DATABASE is aborted.
> > Device activation error. The physical file name
> > 'D:\Bancos\Logs\\contax_log.LDF' may be incorrect.
> >
> > I don't have the LDF file, but I suppose that SQL Server would create a new
> > one. Besides, the physical path in the error message has two slashes (after
> > "Logs" directory), and I found it weird...
> >
> > Could somebody help me?
> >
> > Thanks a lot.
> >
> > Marcos|||> I don't have the LDF file, but I suppose that SQL Server would create a new
> one.
It can, but only under certain circumstances, like db being detached first, only having one log file
etc. If those are not met, you need luck to get it to work. Apparently, it doesn't for you so I
recommend using your most recent backup(s) to get the database back.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Marcos Federicce" <MarcosFedericce@.discussions.microsoft.com> wrote in message
news:EB863B21-0C15-4684-B985-CB0ABDD3DC93@.microsoft.com...
> Hi, All!
> I'am trying to recover a database using sp_attach_db. I just have the .MDF
> file. I tried this command, and receive this result:
> EXEC sp_attach_db 'Contax', 'C:\Arquivos de programas\Microsoft SQL
> Server\MSSQL\Data\Contax.mdf'
> Server: Msg 1813, Level 16, State 2, Line 1
> Could not open new database 'contax'. CREATE DATABASE is aborted.
> Device activation error. The physical file name
> 'D:\Bancos\Logs\\contax_log.LDF' may be incorrect.
> I don't have the LDF file, but I suppose that SQL Server would create a new
> one. Besides, the physical path in the error message has two slashes (after
> "Logs" directory), and I found it weird...
> Could somebody help me?
> Thanks a lot.
> Marcossql

No comments:

Post a Comment