1

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.

2 Answers 2

1

Could this help you?

http://blogs.msdn.com/florinlazar/archive/2005/09/16/469064.aspx

1

http://support.microsoft.com/kb/937517

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.