MSDTC交易
我正在使用链接服务器进行事务
例如
Alter Proc [dbo].[usp_Select_TransferingDatasFromServerCheckingforExample]
@RserverName varchar(100), ----- Server Name
@RUserid Varchar(100), ----- server user id
@RPass Varchar(100), ----- Server Password
@DbName varchar(100) ----- Server database
As
Set nocount on
Set Xact_abort on
Declare @user varchar(100)
Declare @userID varchar(100)
Declare @Db Varchar(100)
Declare @Lserver varchar(100)
Select @Lserver = @@servername
Select @userID = suser_name()
Select @User=user
Exec('if exists(Select 1 From [Master].[' + @user + '].[sysservers] where srvname = ''' + @RserverName + ''') begin Exec sp_droplinkedsrvlogin ''' + @RserverName + ''',''' + @userID + ''' exec sp_dropserver ''' + @RserverName + ''' end ')
Set @RserverName='['+@RserverName+']'
BEGIN TRY
BEGIN TRANSACTION
Declare @ColumnList varchar(max)
Set @ColumnList = null
Select @ColumnList = case when @ColumnList is not null then @ColumnList + ',' + quotename(name) else quotename(name) end from syscolumns where id = object_id('bditm') order by colid
Set identity_insert Bditm on
Exec ('Insert Into Bditm ('+ @ColumnList +') Select * From '+ @RserverName + '.'+ @DbName + '.'+ @user + '.Bditm')
Set identity_insert Bditm off
Commit
Select 1
End try
Begin catch
If (@@ERROR <> 0)
Begin
If @@trancount >0
Begin
Rollback transaction
Select 0
END
End
End Catch
Set @RserverName=replace(replace(@RserverName,'[',''),']','')
Exec sp_droplinkedsrvlogin @RserverName,@userID
Exec sp_dropserver @RserverName
,这是发生的错误:
Microsoft 分布式事务协调器 (MS DTC) 已取消分布式事务。
I am using Linked server for Transaction
example
Alter Proc [dbo].[usp_Select_TransferingDatasFromServerCheckingforExample]
@RserverName varchar(100), ----- Server Name
@RUserid Varchar(100), ----- server user id
@RPass Varchar(100), ----- Server Password
@DbName varchar(100) ----- Server database
As
Set nocount on
Set Xact_abort on
Declare @user varchar(100)
Declare @userID varchar(100)
Declare @Db Varchar(100)
Declare @Lserver varchar(100)
Select @Lserver = @@servername
Select @userID = suser_name()
Select @User=user
Exec('if exists(Select 1 From [Master].[' + @user + '].[sysservers] where srvname = ''' + @RserverName + ''') begin Exec sp_droplinkedsrvlogin ''' + @RserverName + ''',''' + @userID + ''' exec sp_dropserver ''' + @RserverName + ''' end ')
Set @RserverName='['+@RserverName+']'
BEGIN TRY
BEGIN TRANSACTION
Declare @ColumnList varchar(max)
Set @ColumnList = null
Select @ColumnList = case when @ColumnList is not null then @ColumnList + ',' + quotename(name) else quotename(name) end from syscolumns where id = object_id('bditm') order by colid
Set identity_insert Bditm on
Exec ('Insert Into Bditm ('+ @ColumnList +') Select * From '+ @RserverName + '.'+ @DbName + '.'+ @user + '.Bditm')
Set identity_insert Bditm off
Commit
Select 1
End try
Begin catch
If (@@ERROR <> 0)
Begin
If @@trancount >0
Begin
Rollback transaction
Select 0
END
End
End Catch
Set @RserverName=replace(replace(@RserverName,'[',''),']','')
Exec sp_droplinkedsrvlogin @RserverName,@userID
Exec sp_dropserver @RserverName
this is the Error occured:
The Microsoft Distributed Transaction Coordinator (MS DTC) has canceled the distributed transaction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可以帮助你吗?
http://blogs.msdn.com/florinlazar/archive/ 2005/09/16/469064.aspx
Could this help you?
http://blogs.msdn.com/florinlazar/archive/2005/09/16/469064.aspx
http://support.microsoft.com/kb/937517
http://support.microsoft.com/kb/937517