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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling tables from different databases

Status
Not open for further replies.

stevet26

Programmer
Feb 9, 2005
53
Hi

I am wondering whether it is possible to call a table that I have in my master database from a stored procedure in my client databsse. Both databases are on the same server.

If that is not possible, are you able to call another stored procedure instead. I can do this in Query analyser but, cannot get it to work in a sp.

The code I use in query analyser is: dotnetCMS.dbo.spTITLES

Thanks in advance.



 

That's the idea why SQL Server has linked server, search "linked server" in BOL and you will get the answer.
 
Thanks for the handy hint.

I cannot see how linked servers will solve the problem that I have.

As I mentioned before, I want to call a table from a different databse ON THE SAME SERVER.
 
All you have to do is name the database....it would help if you posted the code, but...

SELECT m.phonenumber,
u.lname
FROM Masterdb.dbo.tablename M
JOIN Userdb.dbo.tablename U

Something like that will work, but you need to be able to 'link' the two databases with the ON clause.
If you just want to run a procedure in the user database and have it query the master, that's easier.

USE UserDB
CREATE PROCEDURE ......

SELECT .....
FROM MasterDB.dbo.tablename

-SQLBill


Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top