Friday, October 23, 2009

Linked Server SQL using OpenQuery

If you are trying to find out how to link databases, you might consider creating a linked server. In SQL 2000, you can select the security folder in the Enterprise Manager where you will see a Linked Server option. Select the right mouse button on the linked server and select "new linked server". Type in the name of the other server you want to link to. To query on a linked server, you will use the OpenQuery command.

SELECT * FROM OPENQUERY(servername, 'select * from databasename.dbo.tablename')

the openquery command will query the other server. You will input the server name, and the query that will be used to access the other server.

0 comments: