从同一个Azure SQL Server上的其他数据库调用主数据库的功能
问题描述:
我有Azure SQL数据库服务器+一个Azure SQL数据库。在这个数据库中,我有一些函数调用主DB的一些函数作为其逻辑的一部分。从同一个Azure SQL Server上的其他数据库调用主数据库的功能
例子:
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服务器上使用用户数据库的主数据库功能,是否有解决方案?
为什么使用EXEC insted的SELECT?请仔细阅读,选择master.dbo.fn_varbintohexstr(123) – sepupic
@sepupic。使用exec的示例仅用于获取更适当的错误消息。选择也不起作用。 –
https://stackoverflow.com/questions/11284998/cant-query-between-databases-in-sql-azure – sepupic