Transaction Log
Transaction Log Transaction logs) is a very important but often ignored part of the database structure. Since it is not as active as the schema in the database, few people are concerned about transaction logs.
END
GO
BEGIN TRY
SELECT GETDATE ()
SELECT 1/0--evergreen divide by zero example!
END TRY
BEGIN CATCH
SELECT ' There is an error! ' + error_message ()
RETURN
END CATCH;
2. The function table that obtains the error message:The following system functions are valid in the CATCH block. Can be used to get more error messages:
function
Description
Error_number ()
Returns the error number of the e
, status 0, procedure TT1, 17th rowsThe insert statement conflicts with the check constraint "T1. This conflict occurs in the Database "test", table "DBO. Salary", column 'salary '.The statement has been terminated.
(One row is affected)
No output in the result 111 indicates that the stored procedure is not executed.
Test environment: SQL Server 2005 Express
This is another example:
1.
server| Data | database
Lock is a very important concept in network database, it is mainly used to guarantee database integrality and consistency under multi-user environment. The basic theory of lock used in various large databases is consistent, but it is different in concrete implementation. At present, most database management systems have more or less self-regulation and self-management functions, so many users are actually not
On the weekend, I helped a buddy find a tool to view SQL Server redo logs, which is quite good. I do not dare to enjoy it exclusively. I recommend it to you.
I have successfully installed SQL server on the machine and can connect to use it, but cannot connect to a remote database. The error is: a proxy. cpp file is mi
The Enterprise Edition cannot be installed under XP, So download a Personal Edition
After the installation is complete, the system prompts "MSSQL installation prompt reference Server Error Log and C:/winnt/sqlstp. log for more information"
Solution:
First, delete the Microsoft SQL
Tags: blog http io strong SP on log CTIGet ready:CREATE TABLE Nums (X int);Purpose: Inserts only one row into the table.--------------------------------------------------------------------------------------------------------------- ---------------------- BEGIN TRANSACTION Tran_a-it is best to define a name for the transaction.Insert into Nums (X) VALUES (9); Save Tr
1. It is best to have only one transaction for a stored procedure; multiple transactions consume both resources and are prone to errors;
2. When creating a transaction and ending a transaction, you 'd better have the following judgment:Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->IF @ TRANCOUNT = 0
BEGIN
to specify the name of the maintenance plan. Finish to start the log shipping creation.
Monitor
1. After the log shipping is created, the information associated with log shipping is stored in the 7 tables in msdb:
Log_shipping_plans
Log_shipping_plan_databases
Log_shipping_databases
Log_shipping_plan_history
Log_shipping_monitor
Log_shipping_primaries
Log
Tags: tools generate bind data Delete sql otherwise JPG uploadCompany to replace the computer, clear SQL Server remember the user name and passwordPlease follow the location found in the corresponding file SqlStudio.bin, and then delete it, please put 100 hearts, this file will be automatically generated.Note that you
The examples in this article describe SQL Server triggers and transaction usages. Share to everyone for your reference, specific as follows:
Add and remove triggers
Alter TRIGGER TRI_TC on T_c to
Insert,delete
as
begin
set XACT_ABORT on
declare @INSERTCOUNT int;
Update triggers and transactions
Transactions are primarily used for data protect
. What should I do if I want to delete all records in the SQL Server database? There are two options:
1. delete tables one by one in sequence. This method is unrealistic when there are many tables, even if the number of tables is small, but there are many constraints, you still need to spend a lot of time and energy studying the constraints between them, and then find out which table to delete first, whic
, PersonName)Values ('1', 'name1 ')Insert Into Person (PersonId, PersonName)Values ('3', 'name3 ')Commit TransAction/*Select values include '1', 'name1', and '3', 'name3 ',This indicates that only the error in the second sentence has been canceled.*/
Method 1 for all rollback: Open XACT_ABORT
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Use TestDB
SET XACT_ABORT ON -- open
Begin
The database image solution has two operating modes. One is "high security mode", which supports synchronization operations. In high security mode, when the session starts, the backup storage synchronizes the backup storage with the master database as soon as possible. Once the database is synchronized, the transaction will be submitted by both partners, this will prolong the transaction latency. The second
databases.-- The Instance name is RemoteServer. The local and remote databases submit or roll back the transaction at the same time.-- Note that four naming rules are used for executing distributed queries or calling stored procedures.
-- Prerequisite: the MSDTC Service on the local machine and the MSDTC Service on the remote machine must be enabled.-- The local machine and remote machine can ping each other-- Database ports can be telnet to each oth
Tags: run backup file management clears CTI Trunc set DBCC SQL2008 's shrink log due to SQL2008 's optimization of file and log management, the following statements can be run in SQL2005 but have been canceled in SQL2008: (SQL2005) Backuplog dnname withno_logGo
Dump TransactionDnname withno_logGo
UseDnnameDBCCShrinkfile (2)
Go
--------------------------------------------------------------
(SQL2008): In the
')
GO 2 rollback Cases --the simplest rollback
--The following statements can be executed separately, one line at a time
BEGIN TRAN --open transaction, set transaction start point
/*The command was successfully completed. */
SELECT * fromscore/*(0 rows affected) Description: Because there is no data in the table, the query returns the number of bars to 0.*/
INSERT intoScoreVALUES(101, -)--Insert da
SQL Server lock mechanism (I) Overview (lock type and scope) SQL Server lock mechanism (ii) Overview (Lock compatibility and lockable resources) this article introduces the SQL Server lock mechanism (iii) Overview (lock and
rolled back'
ENDCatch Test commit and rollback transactions are OK. 3. Auxiliary statements -- -Delete table, restore self-increment starting from 1 truncate table testtable -- -display insert self-increment set identity_insert testtable on insert into testtable (testid,testname) values (32 , " 5 " ) identity_insert testtable off Attention: 1.set Identity_insert is only valid for the current session. 2.Set identity_insert table name on set, you must display the specified ID
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.