Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql server 2005 .mdf .ldf files

I have those 2 files (.MDF and .LDF) how could i attach them to microsoft sql server in order to see their content ?

like image 649
Ron Avatar asked Dec 08 '25 10:12

Ron


2 Answers

In Management Studio, in Object Explorer, right-click on the Databases folder.

Choose Attach...

At the top of the section titled "Databases to attach", click the Add button.

In the displayed folders and files, navigate to your .mdf file and click on it.

Click OK.

That's all you have to do.

like image 165
DOK Avatar answered Dec 10 '25 00:12

DOK


Execute this command from SQL command line (such as query analyzer). Replace AdventureWorks with the name you got.

EXEC sp_attach_db @dbname = N'AdventureWorks', @filename1 = N'C:\AdventureWorks_Data.mdf', 
  @filename2 = N'C:\AdventureWorks_log.ldf';

If you don't have query analyzer handy run this from windows command prompt:

 osql -E -S.\sqlexpress -Q"EXEC sp_attach_db @dbname = N'AdventureWorks', @filename1 = N'C:\AdventureWorks_Data.mdf', @filename2 = N'C:\AdventureWorks_log.ldf'"
like image 24
DenNukem Avatar answered Dec 09 '25 23:12

DenNukem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!