sql触发器怎么获取插入的记录转存到另一个数据库的表里?
展开全部
CREATE
TRIGGER
a1_a
ON
[dbo].[a1]
FOR
INSERT
AS
insert
into
b.dbo.b1(g,h,j)
select
c
as
g,d
as
h,e
as
j
from
inserted
在A数据库A1表,加上面的触发器(只限于同一台服务器不通数据库数据转存),如果要在不同的服务器上,就先在A所在服务器上加链接服务器,触发器修改为:
CREATE
TRIGGER
a1_a
ON
[dbo].[a1]
FOR
INSERT
AS
insert
into
[server
name].b.dbo.b1(g,h,j)
select
c
as
g,d
as
h,e
as
j
from
inserted
TRIGGER
a1_a
ON
[dbo].[a1]
FOR
INSERT
AS
insert
into
b.dbo.b1(g,h,j)
select
c
as
g,d
as
h,e
as
j
from
inserted
在A数据库A1表,加上面的触发器(只限于同一台服务器不通数据库数据转存),如果要在不同的服务器上,就先在A所在服务器上加链接服务器,触发器修改为:
CREATE
TRIGGER
a1_a
ON
[dbo].[a1]
FOR
INSERT
AS
insert
into
[server
name].b.dbo.b1(g,h,j)
select
c
as
g,d
as
h,e
as
j
from
inserted
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询