] @InOpenID = ' 1ccd524d-de62-47ca-87d3-38787b040ba3 ', @InTDesc = N ' received the transfer of a ', @OutOpenID = ' 2ccd524d-de62-47ca-87d3-38787b040ba3 ', @OutTDesc = N ' transfer to A100 ', @TAmount = @TTID = 1, @Result = @Result Outputselect@result as N ' @Result ' GOTest 2>: Simulate things with errors, roll backTo cancel a store: SELECT 1+ ' A ' comment (an error occurred in a simulated thing)use [Test]godeclare@return_value int, @Result intexec@return_value = [dbo]. [Paddtransaction] @InOp
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
How can I clear database logs without stopping? Here, we take a database SQL SERVER 2005 as an example. When the log file reaches more than 100 GB, it cannot be cleaned up and many methods have been taken:
For exampleSqlServer log clearing expertUsed to
Tags: BSP span end pre appear ROM transaction user begin ----View additions and deletions do not affect the underlying table
----view does not allow repeating columns
Create Viewhaha--Create a View
as
SelectStudent.*, Score.cno,score.degree fromStudent,scorewhereStudent. Sno=Score.snoSelect * fromhaha----Business
begin Tran
Insert intoUsersValues('Zhao Four','c002')
Insert intoUsersValues('Zhao','c001')
if @ @error>0
begin
rollback Tran;
En
SQL cannot log on to the SQL console= = = Problem description A domain-joined SQL production server, login repeatedly failed to view the error message after the prompt "in the SQL Server
SQL Server database prompts "tempdb" log is full solution, sqlservertempdb
Execute SQL statements. Temporary tables are not used in the middle.
Prompt server: Message 9002, Level 17, status 2, Row 1 Database 'tempdb' logs are full. Back up the
',@ Physname = 'C: \ Program Files \ Microsoft SQL Server \ MSSQL \ data \ database name. 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"
(Sql2005: Property -- option -- Miscellaneous -- Automatic -- automatic shrinking, i
Tags: run right-click Database PNG default transaction file log file LLBObjectiveNext we end up with the last few sections of the SQL Server Basic series, and then we'll talk about SQL Server performance tuning, and we'll get to t
automatically contract in the future, make the following settings:
Enterprise Manager -- server -- Right-click Database -- Property -- option -- select "auto contract"
-- SQL statement setting method:
Exec sp_dboption 'database name', 'autowrite', 'true'
6. If you want to prevent the log from increasing too much in the future
Enterprise Manager --
/* When multiple stored procedures are called in a large SQL statement and multiple stored procedures are called in the called stored procedure, after multiple nested calls, if you need to roll back the entire transaction if the primary key is repeated or the business logic is not met, you can use the following mode for processing. You can also directly count data without raiserror. If an error occurs after
is 0
rollback Tran--rolling back things
Else
Commit Tran--Submit Things
--three paradigms of---database design
--1. The values in each column are single
--2. Meet 1, each table must have a primary key
--3. Satisfy 2, the foreign key table only appears in the primary key table in the primary key column, the other columns do not appear. When there are three columns in a table and more of the data is often duplicated, you need to take these columns out to create a separate table
--set a primary
recommended to truncate logs on the production database unless you have good reasons and are sure enough, or ......You are not responsible for this.
Since this method is not safe, I will introduce a security method below.As we all know, SQL Server will automatically cut off the inactive part of the transaction log wh
Label: You can use log shipping to send transaction logs uninterrupted from one database (primary database) to another (secondary database). Continuously back up the transaction logs in the primary database, and then copy and restore them to the secondary database, which basically keeps the secondary database in sync with the primary database. The target
When the log file is full and the SQL database cannot write the file, you can use either of the following methods:One method: Clear logs.1. Open the query analyzer and enter the commandDump transaction database name with no_log2. open the Enterprise Manager and right-click the database you want to compress -- all tasks
DBCC LoginfoDBCC log (' Qssys ', type=2)GoSELECT * from Sys.fn_dblog (null,null)Select [Dirty pages],[minimum lsn],[checkpoint end],[chkpt Begin DB version],[checkpoint begin],operation,context,[log Record length],allocunitname from Fn_dblog (null,null)SELECT * FROM dbo. T_companyaccount with (NOLOCK)Operation: Operations done by the current LSNCURRENTLSN: Serial number uniquely identified in the
Method 1, Sys.dm_tran_session_transactions;Method 2, DBCC OPENTRAN--------------------------------------------------------------------------------------------------------------- ---------------------------------------------Method 1,Sys.dm_tran_session_transactionsSELECT * from Sys.dm_tran_session_transactions;GoPrint out the activity's transactions.Method 2,DBCC OPENTRANDBCC OPENTRANSummarize:From the results can be seen,Sys.dm_tran_session_transactions all current active transactions.DBCC OPENT
under database a Dbo.prtesta EXEC dbo. Prtesta The following error will appear: The context of the transaction is being used by another session. I believe you already understand what is called loopback link Server , when we change the dbo.prtestb of the stored procedure in database B to cross-library access, such as: SELECT * from B.dbo.test The problem is solved. Therefore, you must pay attention to avoi
the log will not increase, it also means that once you have misoperations, there will be no chance to use the log to recover. (For details about how to use logs to restore data, see the FAQ in the essence area)
Therefore, it is absolutely not recommended to truncate logs on the production database unless you have good reasons and are sure enough, or ......
You are not responsible for this.
Since this metho
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.