Attach databases without log files

  • Hi all. I have some databases that I can sometimes attach to a

    new SQL server (2kE) without the log file,

    and other times I can't.

    It was my understanding that it's not possible to attach a database

    without both the MDF and LDF, but it appears I can do so, usually after a backup and truncate.

    Anyone else seen this?

    Thanks!

  • If the database was detached Properly, You can attach it without LDF.

  • Of course you can, that's why the stored procedure sp_attach_single_file_db exists.

  • Wow. This has been one of those "every day I learn something new is a successful day" days.

    Thanks to both of you!

    Jeff

  • But if you have two or more log files this SP will not work. Read about it there http://qa.sqlservercentral.com/columnists/awarren/attachanddetachagain.asp and there:http://qa.sqlservercentral.com/scripts/contributions/599.asp

  • I'm trying to attach a database and "drop" TWO log files. I've used Andy Warren's article "Attach and Detach - Again" (http://qa.sqlservercentral.com/columnists/awarren/attachanddetachagain.asp). I can successfully attach using one of the log files (the first in order from the original creation of the database). If I use Andy's code, I can't drop the second log file or drop both log files. Neither situation is a real surprise given some of the comments in Andy's article and in other articles, but I still need to resolve this problem some how. Has anyone tried to do what I'm doing? Has anyone had any different experience than this? Thoughts? Comments? I'd appreciate any help anyone can provide. My log files are 18 GB and 4 GB, and I'd like to simply "drop" both when I attach the database. Thanks.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply