Linked Server - Works Except With Insert Statement

  • I am trying to get Job information from ServerB, and populate a Table Variable on ServerA. From ServerA, I am running the following command with a Linked Server to ServerB.

    If I run this by itself from ServerA, I get the expected results in the query window. And if I insert into a table variable from the local server it works file

    EXECUTE [LinkedServer_B].master.dbo.xp_sqlagent_enum_jobs 1,''

    But when I try the 2nd block of code inserting into the table variable from the linked server, I get an error.

    DECLARE @currently_running_jobs TABLE (

    job_id UNIQUEIDENTIFIER NOT NULL

    ,last_run_date INT NOT NULL

    ,last_run_time INT NOT NULL

    ,next_run_date INT NOT NULL

    ,next_run_time INT NOT NULL

    ,next_run_schedule_id INT NOT NULL

    ,requested_to_run INT NOT NULL

    ,request_source INT NOT NULL

    ,request_source_id SYSNAME COLLATE database_default NULL

    ,running INT NOT NULL

    ,current_step INT NOT NULL

    ,current_retry_attempt INT NOT NULL

    ,job_state INT NOT NULL ) -- 0 = Not idle or suspended, 1 = Executing, 2 = Waiting For Thread, 3 = Between Retries, 4 = Idle, 5 = Suspended, [6 = WaitingForStepToFinish], 7 = PerformingCompletionActions

    --Capture Jobs currently working

    INSERT INTO @currently_running_jobs

    EXECUTE [LinkedServer_B].master.dbo.xp_sqlagent_enum_jobs 1,''

    ERROR:

    OLE DB provider "SQLNCLI10" for linked server "LinkedServer_B" returned message "The partner transaction manager has disabled its support for remote/network transactions.".

    Msg 7391, Level 16, State 2, Line 21

    The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "LinkedServer_B" was unable to begin a distributed transaction.

  • I have never been able to do that. regardless of MS DTC settings or the sp_configure settings of remote proc trans.....

    the way i get around it is using sqlcmd to call a saved .sql file that does the work i need / want.

    in this case (you want results of an extended stored procedure).

    I would create a .sql file that creates a temp stored procedure to create a table in the tempdb on the remote server and then insert the results of the extended stored procedure into this tempdb table.

    once the results are in the remote servers tempdb, i can then just run a select into statement with 4 part naming on the local server to get the data.

    if someone else knows how to get around this, I would love to hear about it.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply