Sunday, August 28, 2011

Microsoft SQL - How to attach database having only mdf file

Quick trick - I had only mdf file of database without log file. Following t-sql script allowed me to attach mdf file to SQL:

sp_attach_single_file_db @dbname= 'NewDatabase', @physname= 'C:\Directory\DataBase.mdf'

After I ran this script I have got several messages but database was restored and worked fine.

No comments:

Post a Comment