sql触发器字段
发布时间: 2024-07-28 06:05:07
Ⅰ SQL SERVER 2000 瑙﹀彂鍣ㄥ备綍瀹炵幇涓涓瀛楁电殑鍊奸殢镌鍙︿竴涓瀛楁电殑鍙桦寲钥屼骇鐢熺浉搴旂殑鍙桦寲锛岋纸锷狅纴鍑忥级
浣犵殑浠g爜链変互涓嫔嚑涓闂棰桡细
1. 鍒ゆ柇鏄钖︽槸NULL搴斾娇鐢╥s锛岃屼笉鏄=
2. 淇鏀瑰瓧娈靛煎簲浣跨敤UPDATE璇鍙
鏁呬綘镄勪唬镰佷慨鏀规垚涓嬮溃杩欐牱锛岃瘯璇旷湅
create trigger tigger1 on UserInfo
for insert
as
declare @i1 as int --杩欓噷绫诲瀷瀹为檯搴斾慨鏀逛负a镄勭被鍨
select @i1 = UserInfo.a
from UserInfo join inserted on UserInfo.涓婚敭 = inserted.涓婚敭
if ( @i1 is null)
update UserInfo
set a = UserInfo.b
from UserInfo join inserted on UserInfo.涓婚敭 = inserted.涓婚敭
鍙﹀,绔欓暱锲涓婃湁浜у搧锲㈣喘,渚垮疁链変缭璇
热点内容