B不过你可以试这个
可能会达到你的效果...create table A
(id int identity(1,1),Name varchar(50)) create table B
(id int identity(1,1),Name varchar(50)) go
--drop Table a drop table b
CREATE TRIGGER ta1 ON A
FOR insert
AS
declare @Name varchar(50) , @a int
select @Name=name from inserted
commit
BEGIN TRANSACTION
SELECT @a=count(name) FROM B WHERE name =@name
if(@a=0) begin
insert into B (Name) values (@Name) end go
CREATE TRIGGER ta2 ON B
FOR insert
AS
declare @Name varchar(50) ,@a intselect @Name=name from inserted SELECT @a=count(name) FROM A WHERE name =@name
if(@a=0)
begin
insert into A(Name) values (@Name)
commit
BEGIN TRANSACTION
end goinsert into A(name) values('2')
可能会达到你的效果...create table A
(id int identity(1,1),Name varchar(50)) create table B
(id int identity(1,1),Name varchar(50)) go
--drop Table a drop table b
CREATE TRIGGER ta1 ON A
FOR insert
AS
declare @Name varchar(50) , @a int
select @Name=name from inserted
commit
BEGIN TRANSACTION
SELECT @a=count(name) FROM B WHERE name =@name
if(@a=0) begin
insert into B (Name) values (@Name) end go
CREATE TRIGGER ta2 ON B
FOR insert
AS
declare @Name varchar(50) ,@a intselect @Name=name from inserted SELECT @a=count(name) FROM A WHERE name =@name
if(@a=0)
begin
insert into A(Name) values (@Name)
commit
BEGIN TRANSACTION
end goinsert into A(name) values('2')
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货