Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Linked Server - Works Except With Insert Statement Expand / Collapse
Author
Message
Posted Monday, July 22, 2013 1:11 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, December 11, 2014 6:43 PM
Points: 2,838, Visits: 8,570
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.



Post #1476224
Posted Tuesday, July 23, 2013 5:59 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 4:41 AM
Points: 515, Visits: 1,743
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.
Post #1476522
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse