-- Regularly synchronize data on the server
-- Example:
-- Test environment: SQL Server2000, remote server name: xz, User name: SA, no password, Test Database: Test
-- Tables on the server (query analyzer is connected to a table created on the
1
--
The followingCodeGenerate an 8-digit serial number. The serial number starts with BH and the remaining six digits are serial numbers.
2
--
Function with the new number
3
Create
Function
F_nextbh ()
4
I have been writing the stored procedure recently, considering the applicationProgramScalability and performance: a large number of temporary tables are used. Because the performance of creating temporary tables with create table # temp is very poor,
First, configure two computers first, for detailed steps see http://support.microsoft.com/kb/839279/en-us
Second, create a connection server,CodeAs follows:
Exec sp_addrole server 'srv2', '', 'sqloledb', '192. 168.0.14'
Exec
/*
Test DataCreate Table TMP (a int)Insert into TMP (a) values (1)
*/
-- Include transactions Create Proc Sp_trantest_1 As Begin Tran Update TMPSet A = A + 1 Update TMP Set A = A / 0 If ( @ Error <> 0 )Begin Rollback Tran
We will summarize the transaction from the beginning. Let's start with a simple transaction example. The following example first defines a transaction, and then records the data about a new order to the database. The sample code is as follows:
Use
1Distributed transactions
Http://community.csdn.net/Expert/topic/4874/4874208.xml? Temp =. 298443.
Execute the following statement:
Insert into AA select * From srva. DBA. DBO. ga-
Begin tran
Insert into B select * from AA
Commit
I used to think that key range locking only exists at the serialization isolation level, but the read-committed isolation level also exists in a forum post:
59: 50. spid24s process id = process6463b88 taskpriority = 0 logused = 480 waitresource =
This problem occurs during learning.The database has a number field.Bh00001Bh00002Bh00003Bh00004How to achieve automatic Growth
-- The following code generates an 8-digit serial number. The serial number starts with BH, and the remaining 6 digits
Summary of writing transaction processing methods in SQL Server Stored Procedures, and storing process transactions
This article describes how to write transactions in the SQL Server stored procedure. We will share this with you for your reference.
-- Start transaction
Begin tran
-- Do Not Display count Information
Set nocount on
Declare @ userid varchar (512)
Declare @ A int
Set @ A = 10000
-- Declare a cursor
Declare crmpscontact_cursor cursor
Select [userid] from [gmcc]. [DBO].
What is a transaction? These are database-specific terms. The lazy explained here: it is to treat multiple things as one thing. That is to say, if everyone is on the same ship, they must live together and over together!
Why should I use transactions?
When SET XACT_ABORT is ON, if a running error occurs when a Transact-SQL statement is executed, the entire transaction is terminated and rolled back.
When SET XACT_ABORT is OFF, only the wrong Transact-SQL statement is generated and the transaction
Part 1 Database SQL language
Data manipulation language (DML)
Data Manipulation Language,DMLIncluding insert, delete, and update statements for adding, deleting, and modifying data.
The following table tb_employeeinfo is used as an example:
Create
Transaction definition:
A transaction is a single unit of work. If a transaction succeeds, all data changes made in the transaction will be committed and become a permanent component of the database. If the transaction encounters an error and
Explicit transactions Explicit transaction is a type of transaction in which the designer clearly defines the start and end of the transaction.You can use BEGIN transaction, commit transaction, commit work, rollback transaction, rollback work, and
Our components are relatively available, but our users are picky. Some users have three requirements:
1. Added support for distributed transactions
2. I don't want to write any SQL statements. I just want to do some simple
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.