数据库触发器问题 [英] Problem with database Triggers

查看:106
本文介绍了数据库触发器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,

我有一个特殊的问题.问题如下:

我有两个数据库lmsbnglr和ilog22july.

我要做的是,当我对lmsbnglr数据库的某些表进行任何更改时,对于这些表,应该在ilog22july中反映相同的更改.

所以我为此写了触发器.

Hie all,

I have a peculiar problem.The problem is as follows:

I have two databases lmsbnglr and ilog22july.

What I have to do is when I make any changes to some tables of lmsbnglr database the same change should get reflected in ilog22july for those tables.

So I wrote triggers for these.

CREATE TRIGGER [dbo].[update_binvoicedet_data]
ON [dbo].[BInvoiceDet]
AFTER INSERT
AS

BEGIN

SET NOCOUNT ON;


insert into ilog22july.[dbo].binvoicedet

select * from inserted where where lmsbnglr.dbo.BInvoice.tripstatus=1

END



我收到此错误:

无法绑定多部分标识符"lmsbnglr.dbo.BInvoice.tripstatus".

我要做的是,当我在lmsbnglr中对BInvoiceDet进行更改时,我必须检查Binvoice的tripstatus字段,如果它的值为1,则将数据复制到ilog22july中.

这个怎么做?据我所知,触发器只能在一张桌子上触发.有人可以给我个主意吗?

谢谢你

Swapnil Borkar



I am getting this Error:

The multi-part identifier "lmsbnglr.dbo.BInvoice.tripstatus" could not be bound.

What I have to do is when I make changes to BInvoiceDet in lmsbnglr I have to check the tripstatus field of Binvoice and if it has value 1 then copy the data in ilog22july.

How to do this? As per my knowledge trigger can only be fired on one table. so can anybody give me any idea?

Thanking You

Swapnil Borkar

推荐答案

CREATE TRIGGER [dbo].[update_binvoicedet_data]
ON [dbo].[BInvoiceDet]
FOR INSERT
AS
BEGIN

   SET NOCOUNT ON;

   insert into ilog22july.binvoicedet
   
   select * from inserted where lmsbnglr.dbo.BInvoice.tripstatus=1

END


我认为这对您有用.


i think this will work for you.


这篇关于数据库触发器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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