May 14, 2008 at 8:01 am
I have used to sp_helpserver to get me listing of the link servers on my server; is there there a way to get a listing of tables on the linkserver by the link server name?
May 14, 2008 at 8:23 am
How about
select * from [linkedServer].[dbName].sysobjects where xtype = 'u'
May 14, 2008 at 8:36 am
I gave that a try but i received the following error invalid object name linksername.dbname.sysobjects
May 14, 2008 at 9:06 am
First off, is this a SQL Server linked server? If not, then sysobjects very well may not apply. If it is SQL Server, what version? If it's 2005 try this:
select name
from [LinkedServername].database.sys.objects
where type='u'
DAB
May 14, 2008 at 9:18 am
thanks for the reply; not all the servers are SQL servers. I have an informix, and MySQL server. What i am trying to do is create a user drop list of linked servers (which i can do). What i want is when the user selects one of the linked servers that i can populate another drop list containing the listing of tables on that linked server. At run time the only information i can attain is the basic information provided from SQL (sp_helpserver) which only provides the link server name.
May 14, 2008 at 9:26 am
I don't know anything about Infromix, but for MySQL you can execute the following:
select * from openquery (MYSQL, ' select table_schema, table_name
from information_schema.TABLES; ' )
DAB
May 14, 2008 at 9:37 am
Thank you very much for the quick response.
That provided the data that i wanted. I kicking myself for forgetting about using OPENQUERY to retrieve the information.
I really appreciate the help,
- Mike
May 14, 2008 at 9:41 am
Glad I could help. One more item. Beware if your MySQL instance is running on a *nix server. If that is the case you will need to take case into account as information_schema <> INFORMATION_SCHEMA, etc.
DAB
May 14, 2008 at 6:33 pm
More universal script:
select *
from master.dbo.SYSREMOTE_TABLES (
'linked_server_name',
NULL,
NULL,
NULL,
NULL )
Works not only on SQL Server remote servers but any kind of remote servers, including ODBC connection to files using Jet.OLEDB driver.
_____________
Code for TallyGenerator
May 15, 2008 at 8:47 am
Hi,
is there an equivalent query for SQL 2005?
May 15, 2008 at 8:54 am
INFORMATION_SCHEMA is an ANSI standard, so it should work on most RDBMSes, although I've never tried it on other vendors' platforms. It certainly works on SQL 2000 and 2005.
John
May 15, 2008 at 8:57 am
I think he's asking for a 2005 equivalent of master.dbo.SYSREMOTE_TABLES
May 15, 2008 at 9:00 am
Yes, i tried the query
select *
from master.dbo.SYSREMOTE_TABLES (
'LnkServerName',
NULL,
NULL,
NULL,
NULL )
and it works great on 2000 but on 2005 which we will be upgrading towards in the next few weeks it does not work.
i appreciate the help everyone is providing...
May 15, 2008 at 9:01 am
Yes, I think you're right. However, that appears to be an undocumented table or view in SQL 2000 that didn't survive to 2005. That's the danger of using undocumented features.
John
May 15, 2008 at 9:03 am
This solution should work for 2000 and 2005:
sp_catalogs ' '
DAB
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply