仅在暂存中出现 SqlBulkCopy 错误

发布于 2024-12-01 18:06:28 字数 270 浏览 0 评论 0原文

当我们使用 SqlBulkCopy 时,我们收到以下错误(仅在登台服务器上)。存储过程具有执行权限。并且它们在我们的测试环境中工作正常。那么在舞台环境中需要纠正什么设置才能正常工作呢?请分享您的想法。

批量的目标表需要 ALTER TABLE 权限 复制操作 如果表有触发器或检查约束,但是 'FIRE_TRIGGERS' 或 “CHECK_CONSTRAINTS”批量提示未指定为选项 批量复制命令。

We are getting the following error (only on the staging server) when we use SqlBulkCopy. The stored procedure has execute permissions. And they are working properly in our test environment. So what is the setting to be corrected in stage environment to work it properly? Please share your thoughts.

ALTER TABLE permission is required on the target table of a bulk
copy operation
if the table has triggers or check constraints, but
'FIRE_TRIGGERS' or
'CHECK_CONSTRAINTS' bulk hints are not specified as options
to the bulk copy command.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

智商已欠费 2024-12-08 18:06:28

由于您没有提供任何 SP/Table 定义,因此很难准确判断,但似乎您需要指定 SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints 使其正常工作...和/或授予用户 ALTER TABLE 权限...如果这在一种环境中有效,而在另一种环境中无效,则SP/表定义和/或用户权限必须存在差异...

It is hard to tell exactly since you don't provide any SP/Table definition but it seems that you need to specify SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints to get it to work... and/or give the user ALTER TABLE permission... if this works in one environment and not in another one then there must be a difference either in the SP/Table definitions and/or the user permissions...

一杆小烟枪 2024-12-08 18:06:28

给定问题的根本原因是需要 ALTER TABLE 权限。我们可以通过以下两种解决方案之一来解决该问题。

要么简单地向指定的用户组授予 ALTER TABLE 权限,要么按照说明

  • 禁用约束,这是默认行为。为了保留
    启用约束,使用 -h 选项和 CHECK_CONSTRAINTS
    提示
  • 触发器被禁用,这是默认行为。开火
    触发器,使用带有 FIRE_TRIGGERS 提示的 -h 选项。
  • 使用 -E 选项从数据文件导入标识值。

Root cause for the given problem is ALTER TABLE permission is required. We can resolve the problem by one of the below 2 solutions.

Either simply grant ALTER TABLE permission to the specified user group or follow the instructions

  • Constraints are disabled, which is the default behavior. To keep
    constraints enabled, use the -h option with the CHECK_CONSTRAINTS
    hint
  • Triggers are disabled, which is the default behavior. To fire
    triggers, use the -h option with the FIRE_TRIGGERS hint.
  • Use the -E option to import identity values from a data file.
于我来说 2024-12-08 18:06:28

这个错误对我来说似乎很清楚。在您的暂存环境中,您执行 SQL 命令的用户对您要批量加载到的表没有 ALTER TABLE 权限。根据您问题的措辞,可能还有其他一些正在运行的环境。在这些环境中,用户确实具有 ALTER TABLE 访问权限。

错误消息中指定的替代方案包括使用批量加载命令发出 FIRE_TRIGGERS 和/或 CHECK_CONSTRAINTS 选项。有关如何执行此操作的详细信息,请参阅此处:http ://msdn.microsoft.com/en-us/library/aa225968(v=sql.80).aspx

The error seems pretty clear to me. In your staging environment the user that you are executing the SQL commands as does not have ALTER TABLE permission on the table you are bulk loading into. Based on the phrasing of your question, presumably there is some other environment(s) which are working. In those environments the user does have ALTER TABLE access.

Alternatives, as specified in the error message, include issuing FIRE_TRIGGERS and/or CHECK_CONSTRAINTS options with your bulk load command. See here for more info on how to do that: http://msdn.microsoft.com/en-us/library/aa225968(v=sql.80).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文