How can you recover a SQL Server database if the ldf file has been deleted

Check this. It is explained how to recover the database.


Yes, you can try detaching the database and attaching it using the sp_attach_single_file_db system stored procedure. This will generate a new transaction log file for you. If this procedure fails, you will need to restore from your backup.


but the mdf file is in tact

Yes, but not consistent. Data files are not kept consistent between checkpoints - this is why you need an LDF file.

I suggest a backup. While you MAY be lucky with the sp_attach_single_file_db it is 99.9% a data loss involved.