服务器 'CKTJ' 上的 MSDTC 要启动

解决方案 »

  1.   


    如果在过程里使用连接服务器要加上分布式事务:
    两边启动dtcset  XACT_ABORT on
    set ANSI_NULL_DFLT_ON on
    set ANSI_WARNINGS on BEGIN DISTRIBUTED TRANSACTION
    select *  from OPENDATASOURCE('MSDASQL','DRIVER={SQL Server};SERVER=ip;UID=sa;PWD=密码;').pubs.dbo.jobs
    commit tran或
    select * into 本地库名..表名 from OPENDATASOURCE(
             'SQLOLEDB',
             'Data Source=远程ip;User ID=sa;Password=密码'
             ).库名.dbo.表名insert 本地库名..表名 select * from OPENDATASOURCE(
             'SQLOLEDB',
             'Data Source=远程ip;User ID=sa;Password=密码'
             ).库名.dbo.表名或使用联结服务器:
    EXEC sp_addlinkedserver '别名','','MSDASQL',NULL,NULL,'DRIVER={SQL Server};SERVER=远程名;UID=用户;PWD=密码;'
    exec sp_addlinkedsrvlogin  @rmtsrvname='别名',@useself='false',@locallogin='sa',@rmtuser='sa',@rmtpassword='密码'
    GO
    然后你就可以如下:
    select * from 别名.库名.dbo.表名
    insert 库名.dbo.表名 select * from 别名.库名.dbo.表名
    select * into 库名.dbo.新表名 from 别名.库名.dbo.表名
    go
      

  2.   

    试试把
    update repayacc_info set repayacc_info.balance=a.balance
    from repayacc_info,CKTJ.cktj.dbo.a_sav_card_acc a
    where repayacc_info.repay_acct=a.account_no
    改为:
    update repayacc_info set repayacc_info.balance=a.balance
    from (select a.balance from repayacc_info right join CKTJ.cktj.dbo.a_sav_card_acc a
    on repayacc_info.repay_acct=a.account_no)where repayacc_info.repay_acct=a.account_no
      

  3.   

    --试试用openrowset:set  XACT_ABORT on
    --启动远程服务器的MSDTC服务
    exec master..xp_cmdshell 'isql /S"CKTJ" /U"sa" /P"123456" /q"exec master..xp_cmdshell ''net start msdtc'',no_output"',no_output--启动本机的MSDTC服务
    exec master..xp_cmdshell 'net start msdtc',no_output--进行分布事务处理,如果表用标识列做主键,用下面的方法
    BEGIN DISTRIBUTED TRANSACTION
    update repayacc_info set repayacc_info.balance=a.balance
    from repayacc_info,openrowset('sqloledb','CKTJ';'sa';'123456',cktj.dbo.a_sav_card_acc) a
    where repayacc_info.repay_acct=a.account_no
    commit tran
      

  4.   

    To zjcxc(邹建)
    试过了,还是报错
    服务器: 消息 7391,级别 16,状态 1,行 32
    该操作未能执行,因为 OLE DB 提供程序 'sqloledb' 无法启动分布式事务。
    [OLE/DB provider returned message: 不能在指定的事务处理器中获得新事务。]
    好像是我的机子没有配置执行分布式事务,请问这个该如何配?