Friday, March 30, 2012

No ldf file but have mdf file

Hi there,

I am using Sql Server Express and have an mdf file I want to attach but I don't have the ldf file. Any suggestions?

Thanks,

Eric

Hi Eric,

To add an existing database .mdf file to SQL Server, you can use Attach. Here are the steps.

1. Copy the .mdf file and.ldf (if exists) to another folder.

2. Right click on Databases, and select Attach from the popup menu.

3. In the Attach Databases dialog box, click Add button and select the .mdf file.

4. Click OK to finish, and the database will be attached to your database list in Management Studio.

Thanks.

|||

ThanksNai-Dong.

But I get the following message below when clicking OK. I think there are two problems. One is I have Express edition and the database has a Job script (and Express doesn't have Sql Server Agent), two the database did not close properly. I will try to find another database version. However thank you for your help.

TITLE: Microsoft SQL Server Management Studio Express
----------

Attach database failed for Server 'INDIVIDU-B3MSFN\SQLEXPRESS'. (Microsoft.SqlServer.Express.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

----------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

----------

Could not open new database 'LittleItalyVineyard'. CREATE DATABASE is aborted.
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\LittleItalyVineyard_log.ldf" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down. (Microsoft SQL Server, Error: 1813)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=1813&LinkId=20476

----------
BUTTONS:

OK
----------

|||

Hi Eric,

Just as you said, you'd better to find another database management version and retry the steps above.

Good Luck!

No comments:

Post a Comment