SQLServer 2008跨数据库实例事务处理
托了几天的难题,终于解决了。特分享一下
以下是一个存储过程
CREATE PROCEDURE deleteAccountAll
@id int
AS
SET XACT_abort ON
BEGIN DISTRIBUTED TRAN
delete from AccountCapital where accountid = @id
delete from logininfo where username = @id
delete from CapitalRecord where accountid = @id
delete from [Trade]..[order] where accountid = @id
delete from account where id = @id
if @@error<>0
rollback tran
else
commit tran
GO
其中order表与其他几个表不在同一个数据库实例,若想实现事务操作,具体要注意两点:
1.打开MSDTC服务,即 set XACT_abort on ,若本机没有启动,则运行 net start msdtc
2.对不同数据库实例的访问要注意用[数据库实例名]..[表名]
相关文档:
经常看见有人问,MSSQL占用了太多的内存,而且还不断的增长;或者说已经设置了使用内存,可是它没有用到那么多,这是怎么一回事儿呢?
首先,我们来看看MSSQL是怎样使用内存的。
最大的开销一般是用于数据缓存,如果内存足够,它会把用过的数据和觉得你会用到的数据统统扔到内存中,直到内存不足的时候 ......
if exists (select * from dbo.sysobjects where name='SplitStr' )
drop FUNCTION SplitStr
go
CREATE FUNCTION SplitStr (@splitString varchar(8000), @separate varchar(10))
RETURNS @returnTable ......
package cn.ctgu.edu.ac;
import java.sql.*;
public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String url="jdbc:sqlserver://localhost:1433;Database=网上书店管理系统;integr ......
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
public class CommandInfo
{
public string CommandText;
public SqlPa ......
SQL Server 2000
Installing SQL Server 2000 (E文)
http://msdn.microsoft.com/en-us/library/aa299042(SQL.80).aspx
SQL Server 2000补丁
Microsoft SQL Server 2000 Service Pack 3a
http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=90DCD52C-0488-4E46-AFBF-ACACE536 ......