發表文章

目前顯示的是 11月, 2010的文章

【心得與小品分享】常用諺語10句---(13)

1. To take the bitter with the sweet.      同甘共苦 2. Union is strength.      團結就是力量 3. When fortune knocks, open the door.      機會難再,莫失良機 4. Well begun is half done.      好的開始是成功的一半 5. Where there is a will, there is a way.      有志者事竟成 6. Where there is life, there is hope.      留得青山在不怕沒柴燒 7. Wishful thinking.      如意算盤 8. When you drink the water, remember the spring.      飲水思源 9. You will cross the bridge when you get to it.      船到橋頭自然直 10. You can’t have a cake and eat it too.      魚與熊掌不可兼得

【Trigger】判斷Trigger是Insert Update Delete行為

當 Insert 時,會將資料新增到資料表中外,在 INSERTED 中,也會保留資料。 當 Delete 時,會將資料從資料表中刪除外,也會將資料在 Deleted 中保留。 而 Update 時,是 先將資料表中的資料先刪除再新增 ,所以在 INSERTED 中,會記錄新資料的記錄,而在 DELETED 會保留舊的記錄。 Sample Code: CREATE TRIGGER dbo.TriggerName    ON dbo.TableName    AFTER INSERT,DELETE,UPDATE AS BEGIN  SET NOCOUNT ON;     if (Select Count(*) From inserted) > 0 and (Select Count(*) From deleted) = 0     begin        print ('新增')     end         if (Select Count(*) From inserted) = 0 and (Select Count(*) From deleted) > 0     begin        print ('刪除')     end         if (Select Count(*) From inserted) > 0 and (Select Count(*) From deleted) > 0     begin        print ('修改')     end END GO 參考資料: http://technet.microsoft.com/zh-tw/library/ms189799.aspx

【Trigger】新增record,更新欲變動的欄位

trigger名稱叫: update_orgnqty INSERTED  --->  表示WOR1被INSERT的那些記錄 當WOR1 table中record Insert時 也會更新欲更改的欄位值 完整 : ALTER TRIGGER [dbo].[update_orgnqty]    ON   [dbo].[WOR1]    AFTER INSERT AS BEGIN  SET NOCOUNT ON;         -- insert wor1 table中record時觸發並會執行下面的動作         -- 將剛新增的記錄,來更新欲更改的欄位值   UPDATE WOR1   SET WOR1.U_OrgnQty1 = I.BaseQty   FROM INSERTED I   WHERE I.docentry = WOR1.docentry and I.LineNum = WOR1.LineNum END

【心得與小品分享】常用諺語10句---(12)

1. Tall trees catch much wind.      樹大招風 2. Time and tide wait for no man.      歲月不待人 3. Talk of the devil and he will appear.      說曹操,曹操就到 4. The early bird catches the worm.      一日之計在於晨 5. There is no accounting for tastes.      人各有所好 6. There is no smoke without fire.      無風不起浪 7. Time flies like an arrow.      光陰似箭 8. There is no royal road to learning.      學問無捷徑 9. Time is money.      一寸光陰一寸金 10. Time is the rider that breaks youth.      歲月催人老

【心得與小品分享】常用諺語10句---(11)

1. Strike the iron while it is hot.      打鐵趁熱 2. Small profits and quick returns.      薄利多銷 3. Spring follows winter.      否極泰來 4. Speech is silver, silence is gold.      雄辯是銀,沉默是金 5. Still waters run deep.      大智若愚 6. Sorrow follows pleasure.      樂極生悲 7. To extend the same treatment to all.      一視同仁 8. To put the cart before the horse.      本末倒置 9. There are no feasts in the world which do not break up at last.      天下無不散的筵席 10. Teaching others teaches yourself.      教學相長

【心得與小品分享】常用諺語10句---(10)

1. Put all one’s eggs in one basket.      孤注一擲 2. Pride goes before a fall.      驕者必敗 3. Pride hurts; modesty benefits.      滿招損,謙受益 4. Practice makes perfect.      熟能生巧 5. Piety is the foundation of all virtues.      百行孝為先 6. Pure gold does not fear the furnace.      真金不怕火   7. Prevention is better than cure.      預防勝於治療 8. Provide against a rainy day.      未雨綢缪 9. Rome was not built in a day.      羅馬不是一天造成的 10. Seeing is believing.      百聞不如一見