It is possible to attach the database without a log file using ATTACH_REBUILD_LOG. With the help of the following script, we attach the ASPNETDB database when there is only mdf file.
1 2 3 4 | USE [master] GO CREATE DATABASE [ASPNETDB] ON ( FILENAME = N'C:\D\Backup\Aspnetmdf\aspnetdb.mdf' ) FOR ATTACH_REBUILD_LOG GO |
Because there is not a log file, it creates a new log file as you see below.
You can find the details of the detach and attach operations in the article titled “How To Change The Disk Of Database Files“.
If you want to detach or attach database containing filestream data you may want to read the article “How To Detach and Attach a Database Containing FileStream Data“.