Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Advanced
Aug 4, 2000

Using Distributed Queries on SQL Server 7.0

SQL Sever 7.0 allows developers to execute commands against OLE DB data sources on different servers. In order to execute commands on remote servers, the SQL Server instance where the commands will be issued must be setup properly. This entails adding the remote server to SQL Server's linked server list. Do this by using the sp_addlinkedserver command.

For example, to link a remote SQL Server database that resides on the RemoteDBServer server, you would use the following syntax:

 EXEC master. . sp_addlinkedserver 
@server = 'RemoteDBServer', 
@provider = 'SQLOLEDB', 
@srvproduct = 'SQL Server',
@datasrc = 'RemoteDBServer'
Note that only members of the sysadmin role can set this server option.

Once the remote database has been linked, queries can be executed against it—as long as the remote tables are prefaced using Server.Database.Table Owner.Table Name. For example, the following query would return all rows in the authors table of our RemoteDBServer SQL Server database:

 SELECT * FROM RemoteDBServer.pubs.dbo.authors
Andrew Holliday
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date