且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何执行另一个数据库的存储过程?

更新时间:2022-11-24 21:01:23

您可以完全限定表和存储过程.换句话说,您可以执行以下操作:

You can fully qualify both tables and stored procedures. In other words you can do this:

UPDATE [OtherDB].[Schema].[targetTable] SET ...

看来您已经在proc中执行了此操作.

It appears you are doing this in your proc already.

您还可以使用完全合格的名称来执行存储过程-例如

You can also EXEC a stored procedure using the Fully Qualified name - e.g.

EXEC [OtherDB].[dbo].[usp_TrimAndLowerCaseVarcharFields]

老实说,您的proc看起来不错,您是否收到任何错误消息?如果是这样,请张贴它们.另外,请确保您的用户有权访问另一个数据库.

Honestly, your proc looks fine, are you receiving any error messages? If so please post them. Also, make sure your user has access to the other DB.