Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have two servers

Status
Not open for further replies.

dass

Programmer
Feb 25, 2002
33
0
0
IN
I have two servers server1 and server2
I want to fetch records from both server with single query
using Ip address

like :
Select * from * empower_hold where username not in(
select musername From despatch_dtls)

the 1st query is from server1
and 2nd one from server2

please help me
 
Look up linked servers in BOL. This enables you to refer to another server simply by qualifying it's name:

Code:
SELECT * FROM server_name.db_name.owner.table_name

--James
 
I believe you need to use the full name of the database:

servername.database.owner.tablename.columnname

I don't link servers myself, so you might want to look through the BOL for anything on Linked Servers.

-SQLBill
 
if you are running the query on server1 (assuming you have ran sp_addlinkedserver 'server2name' and have appropriate permission on the linked server)

Select * from empower_hold where username not in(
select musername From server2.database.databaseowner.despatch_dtls)


Matt

Brighton, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top