且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么 SQL Server CE 不允许触发此触发器?

更新时间:2023-02-04 21:26:18

我认为是否将表作为 CE 同步的一部分进行跟踪并不重要.

I don't think it matters whether the table is tracked as part of CE synchronisation or not.

SQL Server Compact Edition 4.0 不支持触​​发器

Triggers are not supported in SQL Server Compact Edition 4.0

SQL Server Compact 和 SQL Server 之间的差异

编辑

根据这篇 MSDN 文章 SQL Server CE 中的 RDA 允许在 RDA 从中提取数据的 SQL Server 表上触发.它还指出,对于跟踪表,可以在将更改推送回 SQL Server 时执行 SQL Server 触发器.

According to this MSDN article RDA in SQL Server CE allows triggers on a SQL Server table that RDA pulls data from. It also states that for tracked tables SQL Server triggers can be executed when changes are pushed back to SQL Server.

触发器.SQL Server Compact Edition 不支持触​​发器.但是,触发器可以驻留在 RDA 拉取的 SQL Server 表上数据来自.对于跟踪表,可以执行 SQL Server 触发器当更改被推送回 SQL Server 时.您可能必须指定在触发逻辑中设置 NOCOUNT ON.这表示不返回受影响的行数,因为响应不受影响的行"导致 RDA Push 方法出错.

Triggers. SQL Server Compact Edition does not support triggers. However, triggers can reside on the SQL Server table that RDA pulls data from. For tracked tables, the SQL Server triggers can be executed when changes are pushed back to SQL Server. You might have to specify SET NOCOUNT ON in the trigger logic. This indicates not to return the number of rows affected, because a response of "no rows affected" causes an error for the RDA Push method.

我会检查您是否在触发器中使用了 SET NOCOUNT ON.

I would check that you are using SET NOCOUNT ON within your trigger.

说了这么多,如上所述,不支持在 SQL Server CE 中使用触发器.

Having said all this, and as mentioned above, the use of triggers in SQL Server CE are not supported.

也许更好的解决方案是创建需要发送的电子邮件的队列表.当这些数据从 SQL CE 推送回您的 SQL Server 时,您可以安排一个 SQL 代理作业来检查队列表并以这种方式发送邮件.

Maybe a better solution would be to create a queue table of emails that are required to be sent. When this data is pushed from SQL CE back to your SQL Server you could schedule a SQL Agent job to check the queue table and send mail that way.