SQL Server: cross database ownership chaining

来源:互联网 发布:电信4g 的网络制式 编辑:程序博客网 时间:2024/05/17 22:11

当通过一个数据库的存储过程来访问另外一个数据库的存储过程时,要考虑cross database ownership chaining,在数据库服务器与单个数据库上均有相关的选项可以进行设置。

对于单个数据库的设置方法:

alter database TestData set db_chaining on

 

另外各个database的Owner建议都设为sa(如果owner不一样的话也不能跨数据库访问表)

 

EXEC sp_configure 'Cross DB Ownership Chaining', '1';
RECONFIGURE 

 

EXEC sp_dboption 'Northwind', 'db chaining', 'true'

 

 

 

原创粉丝点击