Single Attach MDF MSSQL
Some many projects drive me so far to update my blog in these days. So, I want to update my blog when I get free time. In this post, I’ll describe how to reduce our storage size by the way of deleting Log File (.ldf) of MsSQL. Sometimes, Log file is bigger than Data File (.mdf) because it save all transaction of whatever we do to our database. That’s why I want to delete log file (without having risks) and create new log file without having log records. Yap, here we go. First of all, we need to detach our database. Then, delete .ldf file. (if you’re not sure, backup this log file). Then, open Query Analyzer and type following coding.
EXEC sp_attach_single_file_db @dbname = ‘[db_name]‘,
@physname = ‘C:\MSSQL\Data\[mdf_file_name]‘
After that, run it. SQL will create new log file for you. How? Easy. Isn’t it?

