[sql server发布订阅]after触发器执行失败造成复制不成功
2024-10-13 10:23:41
结论:
(以插入而例)
- 发布端的数据插入成功
- 订阅段的数据不会插入
实验
创建一张新表
create table test_subscriber (id int, mark varchar(2),inserttime datetime)
在订阅表上创建触发器
CREATE TRIGGER [dbo].[sf_test]
ON [dbo].[t2]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
insert into test_subscriber
select c1,c2,getdate() from inserted
END
GO
在发布端执行满足条件的插入
如果C2的字段长度<=2,则触发器能够执行成功,那么两端的数据都能得到更新。
insert into t2 values (5,'xx')
订阅端(和发布端一致)
1> select * from t2 where c1=5
2> go
c1 c2
----------- -----------------------
5 xx
(1 行受影响)
1> select * from test_subscriber
2> go
id mark inserttime
----------- ---- -----------------------
5 xx 2015-07-06 22:39:37.227
(1 行受影响)
插入使触发器执行失败的数据
insert into t2 values (6,'3xx')
发布端
1> use sql2008sbs
2> select * from t2 where c1=6
3> go
已将数据库上下文更改为 'sql2008sbs'。
c1 c2
----------- ----------------------------
6 3xx
(1 行受影响)
订阅端
1> select * from t2 where c1=6
2> go
c1 c2
----------- ------------------------
(0 行受影响)
记录表
1> select * from test_subscriber where id=6
2> go
id mark inserttime
----------- ---- -----------------------
(0 行受影响)
最新文章
- [从产品角度学excel 04]-单元格的“衣服”
- 2014鸟人Birdman中文字幕文件下载
- Excel导出的几种方式
- Liferay 6.2 改造系列之二:清理不需要的Portlet
- Java性能提示(全)
- mysql一个事务中有DDL语句的binlog情况
- JQuery判断checkbox选中,jquery获取选中的checkbox
- Hibernate常见错误整理
- 分享一段H264视频和AAC音频的RTP封包代码
- 学习IT技术的技巧
- Android 调用系统的拍相程序进行录像
- C#实现动态网站伪静态,使seo更友好
- Linux Epoll介绍和程序实例
- Unity GUI 用C#和Javascript写法的区别
- 期望dp-hdu-4336-Card Collector
- Java 序列化 序列化与单例模式 [ 转载 ]
- Bootstrap基础学习(二)&mdash;表单
- Android ec环境配置
- Promise(interesting)
- Spring boot+ maven + thymeleaf + HTML 实现简单的web项目