Sometimes due to some hassle or if you are in hurry, you may download a database (.mdf file) directly from somewhere. But, when you try and attach this database in your SQL Server Management Studio you are not able to attach it. This is due to absence of LOG (.ldf) file. But there is a possible workaround for this. You can create or generate a LOG file by executing following query in SQL Server. Here it is:
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL12.JEKISHANMSSQL\MSSQL\DATA\AdventureWorksDW2012_Data.mdf')
Here, I have written the query to recreate a LOG file for AdventureWorksDW2012_Data.mdf file that I had downloaded from codeplex.