The log of database '*** is full. Back up the transaction logs of the database to release some log space.

Source: Internet
Author: User
Tags stack trace

The log of database '*** is full. Back up the transaction logs of the database to release some log space.
Note: An unhandled exception occurs during the execution of the current Web request. Check the stack trace information to learn about this error andCodeDetailed information about the cause of the error.

Exception details: system. Data. sqlclient. sqlexception: the log of the database '***' is full. Back up the transaction logs of the database to release some log space.

Source error:

[No relevant source line]

Source File: C: \ WINDOWS \ Microsoft. NET \ framework \ v2.0.50727 \ temporary ASP. Net files \ Root \ 72899b79 \ f8dff11c \ App_Web_uff-9q5u.28.cs
Row: 0

The possible cause is that there are too many operations such as statistics and sorting, which are too frequent. Solution: optimize the statement.

In the tempdb database attributes, refer to [Automatic File growth] in the [Enterprise Manager] [file attributes] of [transaction logs, check whether the disk space of your log file is sufficient. If not, save the backup and save it elsewhere.
[Note: The name of your database in tempdb.]

1. Clear logs
Dump transaction database name with no_log

2. Compress database files (if not compressed, the database files will not be reduced
Enterprise Manager -- Right-click the database you want to compress -- all tasks -- contract database -- contract file
-- Select log file -- select to shrink to xxm in the contraction mode. Here, a minimum number of MB allowed to be shrunk is displayed. Enter this number directly and click OK.
-- Select data file -- select to shrink to xxm in the contraction mode. Here, a minimum number of MB allowed to be shrunk is displayed. Enter this number directly and click OK.
First, provide a complex method to compress logs and database files as follows: 1. Clear logs
Dump transaction database name with no_log
2. truncate transaction logs:
Backup log database name with no_log
3. Compress database files (if not compressed, the database files will not be reduced
Enterprise Manager -- Right-click the database you want to compress -- all tasks -- contract database -- contract file
-- Select log file -- in the contraction mode, select to shrink to daily Internet access M. Here, a minimum number of M allowed to be shrunk is displayed. Enter this number directly and click OK.
-- Select data file -- in the contraction mode, select shrink to daily Internet access M. Here, a minimum number of M allowed to be shrunk is displayed. Enter this number directly and click OK.
You can also use SQL statements to complete
-- Shrink Database
DBCC shrinkdatabase (customer profile)
-- Contract the specified data file. 1 is the file number. You can use this statement to query: Select * From sysfiles
DBCC shrinkfile (1)
4. To minimize log files (for SQL 7.0, this step can only be performed in the query analyzer)
A. Separate the database:
Enterprise Manager -- server -- database -- Right-click -- detach Database
B. Delete log files in my computer
C. Additional database:
Enterprise Manager -- server -- database -- Right-click -- attach Database
This method generates a new log with a size of more than 500 K.
Or use the code:
The following example separates pubs and attaches a file in pubs to the current server.
A. Separation
E x e c sp_detach_db @ dbname = 'pubs'
B. Delete log files
C. Attach
E x e c sp_attach_single_file_db @ dbname = 'pubs ',
@ Physname = 'C: \ Program Files \ Microsoft SQL Server \ MSSQL \ data \ pubs. MDF'
5. In order to automatically contract in the future, make the following settings:
Enterprise Manager -- server -- Right-click Database -- Property -- option -- select "auto contract"
-- SQL statement setting method:
E x e c sp_dboption 'database name', 'autowrite', 'true'
6. If you want to prevent the log from increasing too much in the future
Enterprise Manager -- server -- Right-click Database -- properties -- transaction log
-- Limit file growth to xm (X is the maximum data file size you allow)
-- SQL statement settings:
Alter database name Modify file (name = logical file name, maxsize = 20)
Note:
Follow these steps. Do not follow these steps.
Otherwise, your database may be damaged.
Generally, steps 4 and 6 are not recommended.
Step 3 is not safe, and may damage the database or lose data
If the log reaches the upper limit in step 1, the subsequent database processing will fail and the log can be restored after being cleared.

In addition, we provide a simpler method, which I have tried and tried repeatedly. We recommend that you use it.
Simpler Method:
1. Right-built Database Properties window-fault recovery model-set to simple
2. Right-built database all tasks-shrink Database
3. Right-built Database Properties window-fault recovery model-set as large-capacity log records

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.