sql触发器怎么 在A表写入的信息时要检测B表存在是否存在 否则不可插入!

2025-02-25 16:17:16
推荐回答(1个)
回答1:

你这个问题的前提是A和B是两个具有完全相同列结构的表。设她们都是只有两列,分别设为列1和列2.
下面是SQL SERVER的查询语言
insert into B
select A.列1,A.列2 from A where not exist select * from B where A.列1=B.列1 and A.列2=B.列2