create trigger TriggerName on Table2 for update,insert
as
if exists(select * from inserted where E=2)
if exists(select * from Table1 where A=(select A from inserted))
update Table1 set B=Inserted.B from Table1,Inserted where Table1.A=Inserted.A
else
Insert Table1 select A,B,C,D from Inserted
as
if exists(select * from inserted where E=2)
if exists(select * from Table1 where A=(select A from inserted))
update Table1 set B=Inserted.B from Table1,Inserted where Table1.A=Inserted.A
else
Insert Table1 select A,B,C,D from Inserted
解决方案 »
- 考考大家一个问题,请进.
- sql server2000如何导入2007格式的EXCEL文件?
- 请帮忙....一张表中有2个主键时,如何使插入的数据有序排列??
- ms-SqlServer2000有沒有函數可以將字符類型的值轉換成數值類型的值?
- 不知这样的情况该怎么处理???
- 为什么备份数据备份不了???
- 怎么没人回答我啊????????
- 如何用程序(vb,dephi)转换DBF到SQLserver中,谢谢!
- google_real的声明
- asp中向sql server 上传照片如何处理!!!
- 看看类似的这种错误,如何解决
- 大家好,我想请问把一数据表备份成文本文件和从文本文件恢复的语句,谢谢大家~~~~~~~~
FOR INSERT, UPDATE, DELETE
ASdeclare @a1 numeric(10)
declare @a2 varchar(10)
select @a1=a from inserted
if @a1=2
begin
select @a1=a from table1 if @a1 is null
begin
update table1 set b=2 where a=@a1
end
else
begin
insert into table1
(a,b,c,d)
select a ,b,c,d from table2 end
end