Çósql´¥·¢Æ÷Óï¾ä
users±í
name companyId companyName
company±í
companyId companyName
1 a¹«Ë¾
2 b¹«Ë¾
µ±Ìí¼Óuser±íʱ,¸ú¾ÝËùÌîµÄusers.comapnyId,Óô¥·¢Æ÷²úÉúusers.companyName¶ÔÓ¦µÄcompany±íµÄcompanyNameÖµ
select companyName from company where companyId =@companyId
SQL code:
create trigger tri_users_insert
on users
instead of insert
as
begin
insert users
select i.name,i.companyId,c.companyName
from inserted i,company c
where i.companyId=c.companyId
end
»òÕß²»ÓÃinstead of£¬²åÈëºóÓô¥·¢Æ÷½øÐиüÐÂ
SQL code:
create trigger tri_users_insert
on users
after insert
as
begin
update u
set u.companyName=c.companyName
from users u,inserted i,company c
where i.companyId=c.companyId and i.companyId=u.companyId
end
Ö§³Ö
ѧϰ
×îºó²»ÒªÓô¥·¢Æ÷ÁË,ÓÃÍâ¼ü¹ØÁª,ÊÖ¶¯Ìí¼Ó.·½±ãʵÓÃ,ά»¤Ò²ºÜºÃ
Ïà¹ØÎÊ´ð£º
sql table±íÓиöÎı¾ÀàÐ͵Äa×ֶΣ¬´æ´¢µÄÄÚÈÝÈ«²¿ÊÇÊý×Ö£¬ÀýÈç2009001£¬2008578ÕâÑùµÄ¸ñʽ£»b×Ö¶ÎÎı¾ÀàÐÍ£¬´æµÄÒ²ÊÇÊý×ÖÀýÈç 001£¬123
aspÀïÃæ strday=100£¬strb=001
ÎÒÏë¶Á³ö£¬´Óa×ֶεÄÊý×Ö°´´óµ½Ð¡µÄË ......
´ó¼ÒºÃ£¬ÇëÎÊÔÚ±íMÖÐÓÐ×ֶΣºa b c d e
ÎÒÏë²é³öÆäÖÐÂú×ãÏÂÃæÈÎÒâÒ»ÏîµÄÊý¾Ý£¬1.×Ö¶Îa µÄÖµ²»ÊÇ ¡®Êé»ò±Ê»ò±¾¡¯ÖÐÈÎÒ»£¬2.aΪÊéµÄʱºò×Ö¶Îb,cÊÇ¿Õ;3.µ±aֵΪ±ÊµÄʱºòdÊÇ¿Õ;4.µ±aΪ±¾µÄʱºòb,d,e¶¼ÊÇ¿Õ;5.È ......
create trigger TR_Delete_pm_WorkCard
on pm_WorkCard
for delete
as
if @@rowcount=0 return
begin tran
update pm_PlanEntry
set FDispatchQty=t4.FDispatchQty - t1.FDispat ......
Êý¾Ý¿âij±í£¬Ï뽫ÆäÖÐf1,f2Á½¸ö×ֶεÄÄÚÈÝ·10±¶£¬Çë½ÌÈçºÎд·¨£¿
update tbl set f1= f1*10£¬f2= f2*10 where id=10451
ÕâÖÖд·¨»áÔì³Éplsql¿¨ËÀ
²»»á°É£¬ÄǸöid=10451 µÄÊý¾ÝÓжàÉÙ°¡~~~~
ÎÒ¹À¼ÆsqlÊDz» ......