仅在暂存中出现 SqlBulkCopy 错误
当我们使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您没有提供任何 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 userALTER 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...给定问题的根本原因是需要 ALTER TABLE 权限。我们可以通过以下两种解决方案之一来解决该问题。
要么简单地向指定的用户组授予 ALTER TABLE 权限,要么按照说明
启用约束,使用 -h 选项和 CHECK_CONSTRAINTS
提示
触发器,使用带有 FIRE_TRIGGERS 提示的 -h 选项。
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 enabled, use the -h option with the CHECK_CONSTRAINTS
hint
triggers, use the -h option with the FIRE_TRIGGERS hint.
这个错误对我来说似乎很清楚。在您的暂存环境中,您执行 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