OPENROWSET 是 "production-safe" 方法吗?

Is OPENROWSET a "production-safe" method?

我正在开发大约 5 年前使用 C# 和 mssql server 2000 开发的桌面应用程序。 这个应用程序使用 OPENROWSET 来加载一些 xls 文件,并且在我工作的机构升级数据库(升级到 msserver 2019 或类似的东西)并且 OPENTOWSET 停止工作之前它工作得很好。

尽管知道有很多程序和方法可以解决这个问题(我不能在服务器上应用 coz 数据库 运行s),我公司的 DBA 告诉我解决这个问题的唯一方法是给应用程序用户的管理员权限,由于安全规则,他不能这样做 - 将问题交给我。现在我必须用其他东西替换 OPENROWSET。

所以问题是:这是真的吗? 熟练的 DBA 没有办法让 OPENROWSET 在 regular/non-admin 用户的远程数据库上工作,修复那些关于权限和链接服务器的错误? OPENROWSET 是否“足够成熟或足够安全”以使其 运行 在当今的生产服务器上使用?

您似乎正试图从数据库中打开 excel 个文件。在这种情况下,默认设置不允许这样做:

https://docs.microsoft.com/en-us/sql/t-sql/functions/openrowset-transact-sql?view=sql-server-ver15#remarks

OPENROWSET can be used to access remote data from OLE DB data sources only when the DisallowAdhocAccess registry option is explicitly set to 0 for the specified provider, and the Ad Hoc Distributed Queries advanced configuration option is enabled. When these options are not set, the default behavior does not allow for ad hoc access.

When accessing remote OLE DB data sources, the login identity of trusted connections is not automatically delegated from the server on which the client is connected to the server that is being queried. Authentication delegation must be configured.

听起来这可能是过去为以前的数据库配置的,但现在看到这一点的 DBA 认为这是一个安全问题。他是否正确在很大程度上取决于你如何使用它,但它听起来确实像是最好避免的东西。

最好在您的 C# 应用程序中加载 excel 文件,然后将 BULK 数据发送到 sql 服务器进行保存。