-
How to query remote servers in sybase
I have a query that i run from one sybase server that grabs data from another
with a remote query. I can execute the query from my MS server using a linked
server and a 4 part name but it wont work from one sybase server to another
using a remote server. It gives an error message that i can only have 2 prefixes
in the name as opposed to a 4 part name.
the code is similar to such:
use DB1
insert into dbo.srvr1table1
select * from server2.database.dbo.table
Here's the code on the remote server
USE master
EXEC sp_addserver 'gasybprod001',ASEnterprise,'gasybprod001'
EXEC sp_serveroption 'gasybprod001',timeouts,'true'
EXEC sp_serveroption 'gasybprod001','net password encryption','false'
EXEC sp_serveroption 'gasybprod001','rpc security model B','false'
The error is:
11:26:27.602 DBMS GASYBPROD003 -- Error: Number (117) Severity (15) State (1)
The object name 'gasybprod001.lancer.dbo.Top5000MasterFor2008' contains more
than the maximum number of prefixes. The maximum is 2.
---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp
-
Re: How to query remote servers in sybase
Somewhere on GASYBPROD003 (eg, within DB1), try the following:
===========================
use DB1
go
-- proxy table name can be anything you wish as long
-- as it meets rules for ASE indentifiers, eg,
-- 'lancer_Top5000MasterFor2008'
create proxy_table lancer_Top5000MasterFor2008
at
'gasybprod001.lancer.dbo.Top5000MasterFor2008'
go
insert into dbo.srv1table1
select * from lancer_Top5000MasterFor2008
go
===========================
If you get an error message about a login failure on gasybprod001 you'll probably need to define a login mapping from
the local dataserver (GASYBPROD003) to the remote dataserver (gasybprod001). See 'sp_addexternlogin' for details.
If you run into other issues/errors then please post back here with:
1 - results of running 'select @@version' on both the local and remote dataserver
2 - results of running 'sp_helpserver' on the local dataserver
3 - results of running 'sp_helpexternlogin' on the local dataserver
4 - the actual/complete SQL that's generating the error message
5 - the complete error message(s) you're receiving
Also make sure that a valid entry for 'gasybprod001' is in the interfaces file used by the GASYBPROD003 dataserver (ie,
GASYBPROD003 needs to know, via the interfaces file, where gasybprod001 is on the network). ("Duh, Mark!" ?)
Tim wrote:
> I have a query that i run from one sybase server that grabs data from another
> with a remote query. I can execute the query from my MS server using a linked
> server and a 4 part name but it wont work from one sybase server to another
> using a remote server. It gives an error message that i can only have 2 prefixes
> in the name as opposed to a 4 part name.
>
> the code is similar to such:
>
> use DB1
> insert into dbo.srvr1table1
>
> select * from server2.database.dbo.table
>
>
> Here's the code on the remote server
> USE master
> EXEC sp_addserver 'gasybprod001',ASEnterprise,'gasybprod001'
> EXEC sp_serveroption 'gasybprod001',timeouts,'true'
> EXEC sp_serveroption 'gasybprod001','net password encryption','false'
> EXEC sp_serveroption 'gasybprod001','rpc security model B','false'
>
> The error is:
> 11:26:27.602 DBMS GASYBPROD003 -- Error: Number (117) Severity (15) State (1)
> The object name 'gasybprod001.lancer.dbo.Top5000MasterFor2008' contains more
> than the maximum number of prefixes. The maximum is 2.
> ---== Posted via the PFCGuide Web Newsreader ==---
> http://www.pfcguide.com/_newsgroups/group_list.asp
-
Re: How to query remote servers in sybase
and a quick test to see if you could connect to the remote
server and run a query there is this:
From the local server
connect to remote_server_name
go
use database_name
go
select * from table_name
where 1 = 2
go
There are other simpler way to test but this test is most
aligne with what you are trying to do.
Cheers,
Dat