In the query analyzer, perform the following three steps in sequence, where databasename is your database file name
1. Clear logs: Dump transaction databasename with no_log
2. truncate transaction logs: backup log databasename with no_log
3. shrink the database: DBCC shrinkdatabase (databasename)
--///////////////////
Begin:Start transaction; # Be sure to have this '; ' number.Attention:MYSQL uses snapshot isolation, which means that a connection can be queried when it is modified.Example:CREATE TABLE T1 (X int);Insert into T1 (X) values (100);Connect A,Start transaction;Update T1Set X = 200;Connection B,Select X from T1; ------Return 100------------------------------------------------------------------------------------
SQL Server's TRUNCATE transaction rollback operation method, servertruncate
We generally think that TRUNCATE is an operation that cannot be rolled back. It will delete all data in the table and reset the Identity column.
If you perform the TRUNCATE operation in the transaction, you can roll back. Otherwise, it will not recover data from the
Delete a message will cascade delete response information, then we need to use the transaction, the following SQL
Copy Code code as follows:
ALTER PROCEDURE [dbo]. [Proc_tb_leaveword_delete]
(
@leavewordID INT,
@record TINYINT OUTPUT
)
As
BEGIN
BEGIN TRY
BEGIN TRANSACTION
DELETE from Tb_leavewordid WHERE leavewordid= @leavewordID
DELETE from
You often need to modify the data in the database through the stored procedure. You need to configure distributed transactions on the source and target database servers. The configuration process is cumbersome, distributed transactions are caused by both the operating system and SQL Server. After reading the article "SQL Serv
Stored Procedure format:CREATE PROCEDURE yourprocedure asbegin SET NOCOUNT on; BEGIN TRY---------------------start catching exception BEIN TRAN------------------start transaction UPDATE A SET a.names= B.names from T1 as A INNER joins T2 as B on a.id =b.id UPDATE A SET a.names= B.names from T1 as A INNER joins T2 as B on a.test =b.test COMMIT TRAN-------COMMIT TRANSACTION END TRY-----------End catch Exceptio
The batch log recovery mode of the SQL Server recovery model.
Do you want to know why the transaction log file is getting bigger and bigger? Transaction logs are sometimes larger than your actual database files, especially in the
1. Transaction replication works normally. An error occurs on a certain day:
I was so scared that I thought I had to redo it.
2. Visit the peak hours, and do not have time to redo it. I am lucky to put my dog on...
3. Use a dead horse as a live horse and try again:
A. Run
Use [distribution] sp_browsereplcmds '0x00093ffa00002a0e00e000000000', '0x00093ffa00002a0e00e000000000'
Obtain the transaction details o
The transaction log (Transaction logs) is a very important but often overlooked part of the database structure. Because it is not as active as the schema in the database, few people are concerned about the transaction log.
The transacti
File command_string cannot contain more than one pair of double quotation marks, which is incorrect, it seems that the SQL Server help file and the product have also encountered the problem of "the specification and the program do not match ...... 2. Clear Database Log FilesThe problem arises: Our Cutting Process is
Zheng Zuo 2006-6-26
During the BizTalk project, BizTalk Server and SQL
The server is not on the same computer, and the SQL adapter is used to send data prompting the error "new transactions cannot be registered to the specified transaction processor". The same problem occurs
Transaction and concurrency
Before learning things and concurrency, we should first understand two concepts:
1. What are things?
Transactions are the basic unit of work in SQL Server. It usually consists of several SQL commands for reading and updating databases, but these operations are not considered final until a co
)
B. do not enable too long transactions in tempdb (logs cannot be truncated, resulting in excessive logs. If the rollback fails, the server goes down)
C generally, the process of intermediate table matching is created in tempdb (fast creation speed depends on the actual situation .)
D The speed of using heap tables in tempdb is good (depending on the actual situation)
How to clear
is generallyusing (DataTable dt = new DataTable ()){}This implicitly calls the Dispose () method at the end of the curly brace, and DT becomes a local variable immediately out of scope, and there is no call error===============================================================How to take the initiative to recycle the =null?===============================================================Gc. Collect ();All objects are considered recycled regardless of how long the object is in memory, but objects re
Over time, you will find that the log files for the database will be up to 20G or more, and you will need the following methods.--first change the recovery model of the database to SimpleALTER DATABASE [Database] SETRECOVERY Simple;GO--to reduce the log file to 1M, the logical name can be obtained by sp_helpfileDBCCShrinkfile ([Database log name],1); GO--Resettin
The sql2008 shrink log is as follows:
The code is as follows
Copy Code
BACKUP LOG dbname to disk= ' Dbname.log 'DBCC shrinkfile (' Dbname_log ', 1)
But remember to perform two times before you can finally perform the contraction;
Shrink database files (if not compressed, database files do not reduce Enterprise Manager--right--the database you want to compress--all tas
.
there is a SQL Server Agent service in SQL Server that has a " job function ", much like a timer trigger ,
using a " job " to execute a specific T-SQL statement or process at a specific time is an efficient and effective method .
2.
Generate forecast Control Table
Msdn provides a good explanation of transaction and error handling.
If you have any questions, you can check that.
Here we will extract some important words.
"If an error prevents the successful completion of a transaction, SQL Server automatically rolls back the transaction
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.