Database link

greenspun.com : LUSENET : SQL Server Database Administration : One Thread

How do I use a select statement to run a query that will select data from different tables in different databases under the same server.

Thanks for your anticipated quick response.

-- Anonymous, August 31, 2000

Answers

Jennifer,

In the FROM clause of the select statement, preceed the table name with the database name and two dots.

For example:

select * from pubs..authors

This is a special case of the four-part name which is in the form: server.database.owner_name.object_name. In this instance you do not need to list the server and you can generally omit the owner_name.

Hope this helps,

Eric

-- Anonymous, September 01, 2000


Moderation questions? read the FAQ