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.涓婚敭
鍙﹀,絝欓暱鍥涓婃湁浜у搧鍥㈣喘,渚垮疁鏈変繚璇
熱點內容