批量插入txt文件

发布于 2025-01-01 14:02:45 字数 334 浏览 1 评论 0原文

有一个 txt 文件,必须将其传递给 sql

当我运行命令时

insert into tb WITH (FIRE_TRIGGERS) (sField) 
select sField
FROM  OPENROWSET( BULK  'C:\import\file.txt',
          FORMATFILE ='C:\import\tbl.xml'
                )
    as t1

,出现输出错误: “FIRE_TRIGGERS”选项无法识别表提示。

有人知道我如何实现这一目标吗?

谢谢。

have a txt file and have to pass it to sql

When I run the command

insert into tb WITH (FIRE_TRIGGERS) (sField) 
select sField
FROM  OPENROWSET( BULK  'C:\import\file.txt',
          FORMATFILE ='C:\import\tbl.xml'
                )
    as t1

I get output error:
"FIRE_TRIGGERS" option is not recognized table hints.

Anyone any ideas how I can achieve this?

Thanks.

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

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

发布评论

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

评论(1

筱果果 2025-01-08 14:02:45

OPENROWSET BULK 的行为与 BULK INSERT 不同。它的行为更接近于 SELECT 和 INSERT,这就是您上面实际执行的操作。

默认情况下,INSERT 应用触发器。
有一个表提示 IGNORE_TRIGGERS 可以覆盖它。

因此,只需删除 WITH (FIRE_TRIGGERS) 提示,触发器就会触发。

拉塞尔

OPENROWSET BULK behaves differently to BULK INSERT. Its behaviour is closer to SELECT and INSERT and that is the operation you are actually performing above.

By default, INSERT applies triggers.
There is a table hint to IGNORE_TRIGGERS to override this.

So just remove the WITH (FIRE_TRIGGERS) hint and the triggers should fire.

Russell

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