Using SQL Server2005 to empty a database can be implemented with the following SQL
Backup Log Dnname with no_log
Go
Dump TRANSACTION dnname with NO_LOG
Go
Use Dnname
DBCC Shrinkfile (2)
Go
However, this stored procedure has been canceled in SQL Server2008, and in 2008 you need to use the following methods to empty the database log
Use [master]
Go
ALTER DATABASE dnname SET RECOVERY simple with no_wait
Go
ALTER DATABASE dnname SET RECOVERY Simplicity--Simple mode
Go
Use Dnname
Go
DBCC shrinkfile (N ' Dnname_log ', one, truncateonly)
Go
Use [master]
Go
ALTER DATABASE dnname SET RECOVERY full with no_wait
Go
ALTER DATABASE dnname SET RECOVERY Full--Revert to complete mode
Go
Additionally, when you attach a database with SQL Server 2008, the prompt file is read-only and the append fails. However, viewing file properties is not read-only. This is due to the use of the sa login database, only files in the data directory can be attached. Need to log on as a system user, or change the SQL Server service account logon status from Network service to local service