Ewen Cartwright
Ewen Cartwright

Reputation: 15668

Is it possible to switch to a database on a linked server using a 'USE' statement in SQL Server 2005?

I've tried the obvious:

USE linkedServerName.databaseName

Which gives me the error:

`Could not locate entry in sysdatabases for database 'linkedServerName'.

If something like this were possible, it'd save me a bunch of clicking around in management studio!

Upvotes: 1

Views: 1531

Answers (1)

Philip Kelley
Philip Kelley

Reputation: 40309

Linked server definitions are designed for use as part of the four-part naming convention:

[LinkedServerDefinition.][DatabaseName.][SchemaName.]DatabaseObject

for example, OtherServer.Database.dbo.MyTable

They might have other uses, but with the USE statement is not one of them.

Would

SELECT * from LinkedServerDefinition.master.sys.databases

help in identifying what databases are "over ther"?

Upvotes: 2

Related Questions