create trigger tr_a_insert
on a
for insert
asupdate b
set ... --楼主没说怎么更新
from inserted i,b
where i.type=b.id
and i.type in (1,2,3)go
on a
for insert
asupdate b
set ... --楼主没说怎么更新
from inserted i,b
where i.type=b.id
and i.type in (1,2,3)go
on a
for insert
as
begin
delcare @type int
select @type =type from inserted
--更新
update b set ....... where B.ID=@type
end
go
AS
BEGIN
DECLARE @A VARCHAR(10),@SQL VARCHAR(8000)
SELECT @A=TYPE FROM INSERTED
SET @SQL='UPDATE TB SET ....... WHERE ID='''+@A+'''' --没说要什么更新
ESEC (@SQL)
END
on a
for insert
as
begin
delcare @type int
select @type =type from inserted
--更新
if (@type = 1)
begin
update b set ....... where B.ID=@type
end
else if (@type = 2)
begin
update b set ....... where B.ID=@type
end
........
else
begin
update b set ....... where B.ID=@type
end
end
go
on a
for insert
as
begin
delcare @type int
select @type =type from inserted
if @type=1
update b set .... where B.id=1
if @type=2
update b set .... where B.id=2
if @type=3
update b set .... where B.id=3
endgo
AS
BEGIN
DECLARE @A VARCHAR(10),@SQL VARCHAR(8000)
SELECT @A=TYPE FROM INSERTED
SET @SQL='UPDATE TB SET ....... WHERE ID='''+@A+'''' --没说要什么更新
if CHARINDEX(','+@A+',',',1,2,3,')>0 --等1或2或3时更新
ESEC (@SQL)
END