急。。关于用trigger有条件复制表!!

rhesus 2002-11-05 10:10:44
比如:
表table1
ID name class score
1 z 1 23
2 s 1 54
3 a 2 56
4 h 5 67

表table2
用trigger语句能把寄数的记录insert到table2中吗?
...全文
72 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hjhing 2002-11-05
  • 打赏
  • 举报
回复
create trigger yourTrigger
on table1 for insert,update
as

insert into table2
select * from inserted
where [ID] mod 2 =1

update table2
set name= A.name,class=A.class,score=A.score
from updated A
where [ID]=A.ID
renmao 2002-11-05
  • 打赏
  • 举报
回复
可以的呀,不过你要控制它才是的!

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧