dbTalk Databases Forums  

Problem with EXEC string on remote server

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Problem with EXEC string on remote server in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike
 
Posts: n/a

Default Problem with EXEC string on remote server - 10-22-2004 , 12:19 PM






I'm trying to run the following code. Here's the preliminary setup stuff:

-- Create linked server connection:
exec sp_addlinkedserver N'REMOTE_SERVER'
, @srvproduct = N''
, @provider = N'SQLOLEDB'
, @datasrc = N'REMOTE_SERVER.ABC.XYZ.COM'

exec sp_serveroption N'REMOTE_SERVER', N'collation compatible', N'false'
exec sp_serveroption N'REMOTE_SERVER', N'data access', N'true'
exec sp_serveroption N'REMOTE_SERVER', N'rpc out', N'true'
exec sp_serveroption N'REMOTE_SERVER', N'rpc', N'true'
exec sp_serveroption N'REMOTE_SERVER', N'use remote collation', N'true'
exec sp_serveroption N'REMOTE_SERVER', N'collation name', N'null'
exec sp_serveroption N'REMOTE_SERVER', N'connect timeout', 0
exec sp_serveroption N'REMOTE_SERVER', N'query timeout', 0

-- Create holding table

CREATE TABLE [dbo].[tmpResults] (
[server_name] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[results] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

.... and here's what's giving me problems:

set nocount on
set quoted_identifier off

declare @srvname sysname,
@strExec varchar (8000)

select @srvname = 'REMOTE_SERVER'
select @strExec = "select '" + @srvname + "', * from openquery (" + @srvname
+ ", 'select @@version')"
insert tmpResults exec (@strExec)

When I get to the 'INSERT' step, I get the following error:

Server: Msg 7391, Level 16, State 1, Line 1
The operation could not be performed because the OLE DB provider 'SQLOLEDB'
was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the
specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB'
ITransactionJoin::JoinTransaction returned 0x8004d00a].

But, when I remove the 'INSERT' and just execute the string, I get:

REMOTE_SERVER Microsoft SQL Server 2000 - 8.00.818 (Intel X86)
May 31 2003 16:08:15
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 3)

The execute string looks like this:
select 'REMOTE_SERVER', * from openquery (REMOTE_SERVER, 'select @@version')

I'm setting my linked server connection using SQLOLEDB because of problems
with our WINS database, and according to BOL's entry 'sp_addlinkedserver'
(Footnote 1 after the table), "This way of setting up a linked server forces
the name of the linked server to be the same as the network name of the
remote SQL Server. Use server to specify the server." Therefore, I can't use
the name of the linked server as the @server parameter, and have to use the
fully qualified name of the server for the @datasrc parameter -- or so it
seems.

Any suggestions / help would be greatly appreciated.

Thanks,

Mike


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.