Use distributed transactions in SQL Server

Source: Internet
Author: User

For details about the configuration of the COM + environment, see the excerptArticleDistributed transactions (1) --- MTS settings

Http://blog.csdn.net/honkerhero/archive/2007/03/28/1544072.aspx

For troubleshooting of running problems, see file SQL Distributed Transaction error solution.

Http://blog.csdn.net/honkerhero/archive/2007/04/06/1553748.aspx

1. Create a remote connection server ------------------------------------- sp_add1_server

Sp_addmediaserver [@ Server =] 'server' [, [@ srvproduct =] 'product _ name']
[, [@ Provider =] 'provider _ name']
[, [@ Datasrc =] 'data _ source']
[, [@ Location =] 'location']
[, [@ Provstr =] 'provider _ string']
[, [@ Catalog =] 'catalog'

For example, exec sp_addmediaserver @ Server = '000000', @ srvproduct = '', @ provider = 'sqloledb', @ datasrc = '192. 168.20.15'

2. Create remote logon ---------------------- sp_add1_srvlogin

Sp_add1_srvlogin [@ rmtsrvname =] 'rmtsrvname'
[, [@ Useself =] 'useself ']
[, [@ Locallogin =] 'locallogin']
[, [@ Rmtuser =] 'rmtuser']
[, [@ Rmtpassword =] 'mtpassword']

Example: exec sp_add1_srvlogin @ rmtsrvname = '000000', @ useself = 'false', @ rmtuser = 'sa ', @ rmtpassword = 'sa'

3. Set Remote Server (this step is optional) -------------------------- sp_serveroption
For more information, see online help!

For example, exec sp_serveroption '123', 'Lazy schema valider', 'true'

4. Execute distributed transactions

Set xact_abort on
Set ansi_null_dflt_on
Set ansi_warnings on
Begin distributed tran

Insert into [2015] .pubs.dbo.jobs (job_desc, min_lvl, max_lvl) values ('cc)
Select * from [2015] .pubs.dbo.jobs
Insert into pubs.dbo.jobs values ('cc', 100,100)
Select * From pubs.dbo.jobs

-- Commit tran

Rollback tran

Related Article

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.