使用两个数据库在SQL中为插入/更新/删除创建单个触发器 [英] Creating a single trigger for Insert/Update/Delete in SQL with Two Database

查看:70
本文介绍了使用两个数据库在SQL中为插入/更新/删除创建单个触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Server 2012.



我需要从First_DataBase TableA创建单个触发器到Second_DataBase TableB



当对TableA进行任何修改时,它会影响TableB



在这个概念中我使用的是两个数据库



无论何时在表A中插入或更新或删除行,都应该影响表B.



TableA的相同列名和表B



如何从单个触发器处理这个?

I am using SQL Server 2012.

I Need to create a Single Trigger From First_DataBase TableA to Second_DataBase TableB

When ever any modification done on TableA it'll affect the TableB

In this concept i am using Two DataBase

Whenever a row is inserted or updated or deleted in Table A, it should be affect the Table B.

Same Columns Name for TableA and TableB

How to handle this from a single trigger?

推荐答案

你为什么不用数据复制这方面的概念。为什么因为手动维护两个数据库并不是一个好主意。



如果您仍想通过触发器执行此操作,请编写一个公共存储过程来处理该任务所有三个触发器。
Why don't you use data replication concept in this regard. Why because maintaining two databases in sync manually is not a good idea.

If you still want to do it through triggers, write a common stored procedure to handle the task in all three triggers.


这篇关于使用两个数据库在SQL中为插入/更新/删除创建单个触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆