SQL Server 2008 Empty database log method

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.