Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Stored procedures

Posted on 2005-04-26
2
Medium Priority
?
227 Views
Last Modified: 2010-03-19
Hello,

Is it possible to have a stored procedure that selects data from tables that are in different databases? If so, could I see an example or if you know any good links on the subject...?

Thanks!
0
Comment
Question by:prederso
2 Comments
 
LVL 28

Accepted Solution

by:
rafrancisco earned 500 total points
ID: 13867097
Yes it's possible:

CREATE PROCEDCURE GetData
AS
SELECT *
FROM Db1.dbo.Table1 A INNER JOIN Db2.dbo.Table2 B
   ON A.ID = B.ID

To select the table, simply use the convention [DatabaseName].[dbo].[TableName].
0
 

Author Comment

by:prederso
ID: 13867116
Thank you!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question