gpt4 book ai didi

sql - 从同一 Azure SQL Server 上的其他数据库调用主数据库的函数

转载 作者:行者123 更新时间:2023-12-02 08:04:51 25 4
gpt4 key购买 nike

我有 Azure SQL DB Server + 一个 Azure SQL 数据库。在这个数据库中,我有一些函数调用主数据库的一些函数作为其逻辑的一部分。

示例:

CREATE FUNCTION [dbo].[EncryptByKey]
(
@EncryptionKeyId nvarchar(1024),
@ValueToEncrypt varchar(MAX)
)
RETURNS VARCHAR(MAX)
AS
BEGIN
RETURN master.dbo.fn_varbintohexstr(ENCRYPTBYKEY(Key_GUID(@EncryptionKeyId), @ValueToEncrypt))
END

给我一​​个错误:

Cannot find either column "master" or the user-defined function or aggregate "master.dbo.fn_varbintohexstr", or the name is ambiguous.

如果我尝试:

exec master.dbo.fn_varbintohexstr(123)

我得到的错误是:

Reference to database and/or server name in 'master.dbo.fn_varbintohexstr' is not supported in this version of SQL Server.

是否有关于如何从 Azure SQL 服务器上的用户数据库使用主数据库功能的解决方案?

最佳答案

您无法在 SQL Azure 上使用包含三个或四个部分名称的分布式数据库查询。

对于跨越 SQL Azure 中多个数据库的查询,您需要使用弹性查询。欲了解更多信息,请访问this文章。

关于sql - 从同一 Azure SQL Server 上的其他数据库调用主数据库的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46771526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com