Stored procedures

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!
predersoAsked:
Who is Participating?
 
rafranciscoCommented:
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
 
predersoAuthor Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.