2012年2月11日星期六

Answer to your question

Hope someone can help me with this question.

I am wondering if it's possible to create a stored procedure in a database that retrieves data from a table in another database.

database1 has dbo.table1

database2 has stored procedure db1_getTable1data

-- Insert statements for procedure here

SELECT *

FROM [database1][dbo].table1

WHERE PC_ID = @.PC_ID

any help would be greatly appreciated.

Thanks

Rod

Hi,

you are close:

SELECT *

FROM [database1].[dbo].table1

WHERE PC_ID = @.PC_ID

So you can use the three part name: Database.Owner.Objectname (whereas owner has to be replaced by Schema name for SQLServer2005)

HTH, Jens Suessmeyer.


http://www.sqlserver2005.de

|||Thanks Jens, that worked.|||Cool, could you mark the post as "solved", please ?

没有评论:

发表评论