SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 querying data from a database in another db server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

lemx67
Starting Member

6 Posts

Posted - 12/12/2012 :  06:20:43  Show Profile  Reply with Quote
How do I cross database servers?

I mean, how do I query a table that belongs to a different database in a different database server? I need to do this in a stored procedure.

I read somewhere about using spaddlinkedserver, but is there a way to do this using maybe the IP or name of the db server?

Thanks for your assistance.

senthil_nagore
Flowing Fount of Yak Knowledge

India
1007 Posts

Posted - 12/12/2012 :  06:25:06  Show Profile  Visit senthil_nagore's Homepage  Send senthil_nagore a Yahoo! Message  Reply with Quote
You have to configre the linked server first. Then you can specify ip address/server_name in your query to fetch the data from the remote server.

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page

lemx67
Starting Member

6 Posts

Posted - 12/12/2012 :  07:06:41  Show Profile  Reply with Quote
Can you do that within the stored procedure?

would you kindly give me an example?
Go to Top of Page

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/12/2012 :  12:43:59  Show Profile  Reply with Quote

Can we know what exactly you are doing?
Go to Top of Page

lemx67
Starting Member

6 Posts

Posted - 12/20/2012 :  22:13:24  Show Profile  Reply with Quote
I am doing a query on some tables on database A, but somewhere along the way I realize that I need the data from another system which uses database B on another server (both SQL Server). I can login to database B and see the data, but I need to do this within a stored prcoedure, and join a table in database B to my queries in database A.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 12/21/2012 :  01:02:06  Show Profile  Reply with Quote
see below to understand on how to setup a linked server

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=164892

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000