Urgent -- need to attach database but don't have ldf

A client sent me xxxx.mdf without the associated xxxx.ldf.  Is there any way to go ahead and attach this database?

I tried creating my own xxxx database, which of course created an xxxx.ldf, then detached it.  Then I tried to attach the correct xxxx.mdf w/the newly created xxxx.ldf, and of course that didn't work.

Can this be done?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
This may have an answer for you if you have or acquire an account:

Attaching a database that has missing log file
Attach the database using sp_attach_db (see BOL for syntax). If you are lucky, SQL will re-create the ldf file for you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

sp_attach_single_file_db [@dbname =] 'dbname',
    [@physname =] 'physical_name'

for cases when you don't have the ldf ...

don't forget you still need to sort out the "orphaned" users once the database is created on your server.

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

gary_jAuthor Commented:
using this command:

sp_attach_single_file_db @dbname = 'mydb',
      @physname = 'e:\sqldata\mydb.mdf'

returns this error:

Server: Msg 1813, Level 16, State 2, Line 1
Could not open new database 'mydb'. CREATE DATABASE is aborted.
Device activation error. The physical file name 'c:\sqllogs\mydb.ldf' may be incorrect.

Seems it's looking for the ldf on its own ...
Unfortunately, those functions only work if you user the dettach function before on the server!

Have a look at:
gary_jAuthor Commented:
I split the points because the correct answer may well have been "it can't be done" but everybody tried.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.