Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 querying data from a database in another db server

Author  Topic 

lemx67
Starting Member

6 Posts

Posted - 2012-12-12 : 06:20:43
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
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2012-12-12 : 06:25:06
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 - 2012-12-12 : 07:06:41
Can you do that within the stored procedure?

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

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2012-12-12 : 12:43:59

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

lemx67
Starting Member

6 Posts

Posted - 2012-12-20 : 22:13:24
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

52326 Posts

Posted - 2012-12-21 : 01:02:06
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
   

- Advertisement -