Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is there a way to extract SQL Server files (.mdf & .ldf) from a backup file (.bak) to a physical location, without restore database?

I need a restore query or script to restore files from bak file only, no attaching to server. Please don't speak about detaching query after restore.

share|improve this question
    
Not possible I'm afraid. If you can explain why you want to do this, we may have other suggestions that could help. –  Mark Storey-Smith Jun 24 '12 at 10:35
    
I have many customers and sometimes they give me backup for fix some issue. I want to restore their backup as ms sql files and use them in local file without attaching to sql server (connection runtime attaching) –  Hamid Jun 24 '12 at 10:55
6  
If you know how to 'use' an MDF w/o attaching it to a runtime SQL Server then I'm confident you know perfectly well how to extract an MDF from a BAK... –  Remus Rusanu Jun 24 '12 at 11:55
    
When you use runtime attaching of a database, it still must be attached to an instance of SQL Server. Are you connecting to a remote instance of SQL? Are you working with a local instance of SQL Express? Are you using a local SQL Express User Instance? Do you have access to the source code for the utility to work with the MDF and LDF files? –  Brandon Jun 24 '12 at 13:39
2  
Real men run queries in a hex editor! –  Andomar Jun 24 '12 at 15:16
add comment

2 Answers 2

ApexSQL has recently released a tool that can do this. It's ApexSQL Restore. I haven't tested it fully yet, but you have to connect to a SQL Server instance to do this. It attaches database backup file and creates MDF and LDF files for the database.

share|improve this answer
add comment

RedGate software has a product called SQL Virtual Restore which will allow you to attach the backup file to an instance without restoring it and get out the information that you need. This is your only option without using a hex editor.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.