Çó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
Ö§³Ö
ѧϰ
×îºó²»ÒªÓô¥·¢Æ÷ÁË,ÓÃÍâ¼ü¹ØÁª,ÊÖ¶¯Ìí¼Ó.·½±ãʵÓÃ,ά»¤Ò²ºÜºÃ
Ïà¹ØÎÊ´ð£º
ÓÐÒ»¸ö±íAA
name tj
1 a
1 b
1 c
2 a
2 d
3 b
ÒªÇóµ±tj×ֶεÄÖµ¼ÈµÈÓÚaÓÖµÈÓÚcʱ£¨tj = ¡®a¡ ......
µã»÷¡°·þÎñ¹ÜÀíÆ÷¡±£¬µã»÷¡°¿ªÊ¼/¼ÌÐø¡±£¬×ÜÊÇÏÔʾ¡°ÓÉÓڵǼʧ°Ü¶øÆô¶¯·þÎñ¡±£¬È»ºóÔٴγö´í£¬²»Äܹ»½øÈ룬Ҳ²»Äܹ»²é¿´ÊôÐÔ£¬ÇëÎÊ´ó¼Ò¸ÃÔõô°ì£¿
ÎÒÊDzſªÊ¼Ñ§Ï°Êý¾Ý¿â£¬ÇëÎÊ´ó¼ÒÓÐûÓÐʲôºÃһЩµÄ½¨Òé»òÕ ......
INSERT INTO StudAchieve(studID,studName)
VALUES('2','abc'),('2','bcd'),('2','cde')
Æ´ÁË°ëÌìÒ²²»¶Ô£¬¼°°¡ ¡£¡£¡£¡£
SQL c ......
¾ÍÊÇÕ¹¿ªreplication ÓÒ¼üµ¥»÷ local Subscription ´´½¨·¢²¼£¬ ÓÐÈËÓùýÂ𣬳ɹ¦´´½¨·¢²¼µÄÓÐÂð£¿
Óùý£¬¿ÉÒԳɹ¦
ÒýÓÃ
Óùý£¬¿ÉÒԳɹ¦
Ã×ÓùýµÄ°ï¶¥
ÒýÓÃ
Óùý£¬¿ÉÒԳɹ¦
µÚÒ»²½ÎҾ͹ý² ......
Êý¾ÝÀàÐÍ£º
Code char(6)
CreateTime datetime
Price float
Êý¾ÝÈçÏ£º
Code CreateTime Price
031002 2008-10-17 15:00:15 ......