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.
Printable View
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.
Are you getting Microsoft SQL Server, error – 5120?
Yes, I am getting this eror
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!
Thank you so much.