# Database Discussions > Microsoft SQL Server 2008 >  Issue with .mdf file

## Stanley

I was trying to attach .mdf file with the help of SSMS but I do not have .ldf file. I click on the attach option and add the .mdf file. Now it is showing the error message to me.

----------


## ted

Are you getting Microsoft SQL Server, error  5120?

----------


## Stanley

Yes, I am getting this eror

----------


## ted

you can solve this issue by using T-SQL :

CREATE DATABASE [YourDatabaseName] ON
 (FILENAME = 'C:\123\YourDatabaseName.mdf')
FOR ATTACH_REBUILD_LOG ;

Or, you can also use a stored procedure:

EXEC sp_attach_single_file_db @dbname=' YourDatabaseName',
@physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQL \MSSQL\DATA\ YourDatabaseName.mdf'
GO

If a single log file is missing.

Good Luck!

----------


## Stanley

Thank you so much.

----------

