all groups > sql server programming > october 2005 >
You're in the

sql server programming

group:

Information Schema Query on linked server fails.


Information Schema Query on linked server fails. MLokhandwala
10/31/2005 9:04:02 PM
sql server programming:
Hi, We had a simple application which compared schemas on local servers. We
are updating it to compare schemas across servers. Unfortunately the query
which refers to the Information_Schema fails, and I cant find any syntax to
make it work!

Here is the simplified version of the query.

SELECT 1 FROM [Matrix].[ReviewRecorder].[DBO].INFORMATION_SCHEMA.TABLES

tried the following combinations out of frustration, but none worked.
SELECT 1 FROM [Matrix].[ReviewRecorder].[INFORMATION_SCHEMA].TABLES

SELECT 1 FROM [Matrix].[ReviewRecorder].[DBO].[INFORMATION_SCHEMA].[TABLES]

Obviously Matrix is the name of the remote Database Server, and it has been
linked already to the local Database.

The error i get is
------
The object name 'Matrix.ReviewRecorder.DBO.INFORMATION_SCHEMA.' contains
more than the maximum number of prefixes. The maximum is 3.
------

sp_linkedservers shows
---------
Matrix SQLOLEDB SQL Server Matrix NULL NULL NULL
---------

HELP !

Thanks
RE: Information Schema Query on linked server fails. John Bell
11/1/2005 12:20:02 AM
Hi

Have you tried using select * from
{RemoteSvr}.{dbname}.information_schema.tables

Substitute the name in {RemoteSvr} and {dbname}

John

[quoted text, click to view]
RE: Information Schema Query on linked server fails. MLokhandwala
11/9/2005 6:49:00 AM
Yes,

I have tried all combinations, including dropping the owner name etc. but no
luck.
Any other suggestions are welcome.

Still awaiting a solution.

Mohammed


[quoted text, click to view]
RE: Information Schema Query on linked server fails. John Bell
11/9/2005 8:11:05 AM
Hi

It seems 4 part naming only works in master!!!! You could try either calling
a stored procedure in the remote database or creating a view e.g.

-- On Remote Server database run:
CREATE VIEW MyTables AS SELECT * FROM INFORMATION_SCHEMA.TABLES

-- From Local Server Access Remove server
SELECT * FROM Matrix.ReviewRecorder.dbo.MyTables

John


[quoted text, click to view]
Re: Information Schema Query on linked server fails. sualeh.fatehi NO[at]SPAM gmail.com
11/28/2005 4:29:24 AM
If you are willing to use Java, there is a free open-source tool called
SchemaCrawler on SourceForge that can compare schemas between databases
on two different servers. Download SchemaCrawler from:
http://sourceforge.net/project/showfiles.php?group_id=148383
AddThis Social Bookmark Button