Attach Database without Log File - SQL 2005

While trying to attach a Database without a logfile with the procedure sp_attach_single_file_db we get the following error message:

The log cannot be rebuilt because the database was not cleanly shut down.

The database is not detached, before the logfile hase been lost.

When we create a new Databse with the same name and path, stop the sql server, replace with the original .mdf and start the sql server, the Database is visible but there are no items in the tree.

While trying to use: ALTER DATABASE Databsename SET EMERGENCY
we get the error: Access denied.

What can we do?
staugustAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

pjcooleCommented:
Try these steps.

1 create a database with the same name in another directory as the one you're trying to attach
2 re-create all filesgroups and files as necessary
3 shutdown the server
4 swap in the old mdf file and any ndf files
5 bring up the server and let the database attempt to be recovered and then go into suspect mode
6 put the database in single_user and emergency modes
7  run DBCC CHECKDB (dbname, REPAIR_ALLOW_DATA_LOSS) which will rebuild the log and run full repair
8  return database to online, multi_user mode
0

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
staugustAuthor Commented:
(Step 5) How can I let the database attempt to be recovered and how do I go into suspect mode?
0
pjcooleCommented:
When you try to start the database it will try to recover on it own.  Then it will go into suspect mode because it knows something is wrong.  That is part of the startup process when starting up a database.
0
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 2005

From novice to tech pro — start learning today.