gpt4 book ai didi

sql-server - 创建了到 Azure 的远程服务器链接,但未显示 dbo 架构

转载 作者:行者123 更新时间:2023-12-03 06:42:21 28 4
gpt4 key购买 nike

我正在开发一个 Web 应用程序,该应用程序在生产中连接到 Azure 数据库,但在我的本地环境中连接到在 Docker 中运行的 SQL Server。我希望我的本地数据库链接到 Azure 数据库,以便我可以轻松地从生产环境复制数据。我能够通过这些命令成功链接:

EXEC sp_addlinkedserver
@server='remote',
@srvproduct='',
@provider='sqlncli',
@datasrc='mydb.database.windows.net',
@location='',
@provstr='',
@catalog='mydb';

EXEC sp_addlinkedsrvlogin
@rmtsrvname = 'remote',
@useself = 'false',
@rmtuser = 'my_username',
@rmtpassword = 'my_password';

EXEC sp_serveroption 'remote', 'rpc out', true;

...但是,尽管我可以连接并使用应用程序本身使用的相同用户名和密码,但我无法在 dbo 架构中看到我的对象,只能看到 sysINFORMATION_SCHEMA

为什么我在链接到远程 Azure 数据库时无法看到 [remote].[mydb].[dbo].* 对象?尝试选择时出现此错误:

Msg 7314, Level 16, State 1, Line 1The OLE DB provider "MSOLEDBSQL" for linked server "remote" does not contain the table ""mydb"."dbo"."my_table"". The table either does not exist or the current user does not have permissions on that table.

最佳答案

Have you looked at the table's permissions?

这似乎是权限问题。您的查询是正确的。

作为一条建议,请尝试使用已被授予对特定表/数据库的选择权限的特定用户连接服务器。

GRANT select ON DATABASE::database_name TO username;
GO

来自 Azure SQL 数据库的数据:

enter image description here

链接服务的输出:

enter image description here

关于sql-server - 创建了到 Azure 的远程服务器链接,但未显示 dbo 架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74408385/

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