最新整理sqlserver触发器存入远程数据库[精品].docVIP

  • 62
  • 0
  • 约2.53万字
  • 约 26页
  • 2017-01-04 发布于河南
  • 举报

最新整理sqlserver触发器存入远程数据库[精品].doc

最新整理sqlserver触发器存入远程数据库[精品]

SQL code 通过触发器实现数据库的即时同步 即时同步两个表的实例: --测试环境:SQL2000,远程主机名:xz,用户名:sa,密码:无,数据库名:test --创建测试表,不能用标识列做主键,因为不能进行正常更新 --在本机上创建测试表,远程主机上也要做同样的建表操作,只是不写触发器 if exists (select * from dbo.sysobjects where id = object_id(N[test]) and OBJECTPROPERTY(id, NIsUserTable) = 1) drop table [test] create table test(id int not null constraint PK_test primary key ,name varchar(10)) go --创建同步的触发器 create trigger t_test on test for insert,update,delete as set XACT_ABORT on --启动远程服务器的MSDTC服务 exec master..xp_cmdshell isql /Sxz /Usa /P /qexec master..xp_cmdshell net start msdtc,no_output,no_output --启动本机的MSDTC服务 exec

文档评论(0)

1亿VIP精品文档

相关文档