当前位置:数据库 > SQLServer >>

sql server 如何判断是插入行为还是删除行为 像oracle那样 if inserting if deleting

我想只用一个触发器实现删除插入更新
答案:select @id_i=id from inserted
select @id_d =id from deleted
 
if @id_i is not null and @id_d is null  -- 插入操作
begin
end
else if @id_i is not null and @id_d is not null --更新操作
begin
end
else if @id_i is null and @id_d is not null --删除操作
begin
end
其他:好久不用 SQLserver了,你可以用trigger , 隐约记得有inserted deleted 2张表~ 

上一个:请高手帮帮忙,关于sql server数据库表查询问题,麻烦大家了!
下一个:SQL Server代理(SQLEXPRESS)启动不了怎么办,出现

Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,