当表具有触发器时,从 SAS 9.2 到 SQL Server 2005 的 INSERT 失败

发布于 2024-09-14 19:52:23 字数 386 浏览 5 评论 0原文

我通过 SAS/Access ODBC 驱动程序从 SAS 9.2 连接到 SQL Server 2005 DB。 在数据库中,我有一个表 my_table,它有一个 INSERT 触发器,可将所有插入的行复制到数据库中的另一个表中。在SQL Server环境下,触发器工作正常。然而,SAS Proc SQL 似乎不太适合带有触发器的表。以下语句

proc sql ;
    INSERT INTO my_db.my_table
    SELECT a, b, c
    FROM my_db.my_test_table ;
quit ;

在没有触发器的情况下运行,没有任何抱怨,但是当我启用触发器时,它挂起!

有人能解释一下吗?

I connect to an SQL Server 2005 DB from SAS 9.2 via SAS/Access ODBC Driver.
In the DB, I have a table my_table, which has an INSERT-trigger that copies all the inserted rows into another table in the database. In the SQL Server environment, the trigger works normally. However, SAS Proc SQL doesn't seem to get on well with a table with trigger. The following statement

proc sql ;
    INSERT INTO my_db.my_table
    SELECT a, b, c
    FROM my_db.my_test_table ;
quit ;

runs without complaint w/o the trigger, but when I enable the trigger, it hangs!

Could anyone shed a light to this?

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

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

发布评论

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

评论(1

山人契 2024-09-21 19:52:23

尝试确保触发器以这行代码开头:

SET NOCOUNT ON 

这可以防止 sql server 返回受操作影响的记录数。

Try to make sure that the triggers start with this line of code:

SET NOCOUNT ON 

This prevents the sql server from returning the number of records affected by an operation.

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