2010年4月25日 星期日

SQL Server 常用命令

數值

[三位一撇]

假設欄位 f1 為 int 或是 float (不含小數點)

以下可能會出現 123,456.00
select convert(varchar(20), cast (f1 as money), 1)
為了去掉 .00 (MS 預設會帶出的值,沒辦法, 因為是從 money cast 出來)
上述再轉一下
select replace( convert(varchar(20), cast (f1 as money), 1) , '.00', '')

日期

[區間查詢] (d1 到 d2)

假設日期儲存時沒有時間部分

select * from tbl where dt between d1 and d2

假設日期儲存時有時間部分
select * from tbl where dt >= d1 and dt < (d2 + 1)

逼不得已才用 (影響 Performance)
select * from tbl where convert(varchar(dt, varchar(10), 111)) between 'YYYY/MM/DD'
and 'YYYY/MM/DD'


[民國年日期顯示]

output example: 98年1月1日
SELECT CAST(YEAR(getdate()) - 1911 AS NVARCHAR(3)) + '年'
+ CAST(Month(getdate()) AS NVARCHAR(2)) + '月'
+ CAST(Day(getdate()) AS NVARCHAR(2)) + '日'

output example: 98/1/1
SELECT CAST(YEAR(getdate()) - 1911 AS NVARCHAR(3)) + '/'
+ CAST(Month(getdate()) AS NVARCHAR(2)) + '/'
+ CAST(Day(getdate()) AS NVARCHAR(2))

output example: 098/01/01
SELECT RIGHT('000' + CAST(year(getdate()) - 1911 AS VARCHAR),3) + '/' + substring(convert(varchar(10), getdate(), 111), 6, 5)

output example: 0980101
SELECT RIGHT('000' + CAST(year(getdate()) - 1911 AS VARCHAR),3) + substring(convert(varchar(10), getdate(), 112), 5, 4)

2010年4月23日 星期五

好用的 Free Mail Server

MailEnable 是公司最近使用的 Sever
主要是好設定,不要錢

2010年4月11日 星期日

PTSD


精神疾病屬於創傷後壓力症候群(Post-traumatic stress disorder;PTSD),這是遭遇(或對抗)重大壓力後心理狀態失調的後遺症,症狀包括惡夢、失眠、性格丕變、疏離感、逃避會引發創傷回憶的事物、易怒、過度警覺、失憶和易受驚嚇。

我想軍人或是工作壓力大的人都容易發生

在資訊界當主管的人可以檢查一下是否會有此情況

還是要懂得放下吧

2010年4月6日 星期二

複製 .ASPX

當開發內容幾乎相同的 .ASPX (例如 A.aspx, B.aspx)
最省時間的就是先寫好 A.aspx
再複製成 B.aspx
不過不小心其中的有程式相依的關係時
compiler 救會報一堆錯誤

其實只要注意幾點就可以解決:
1. 複製 A.aspx
2. Rename "複製 A.aspx" 成 "B.aspx"
3. 將 B.aspx 開頭 Inherits 部分 改成 B, VS 會在 Rename 時把 CodeBehind 的部分改好
4. Rename B.aspx.cs 中的 class name
5. B.aspx.designer.cs 不用改, 因為 VS 也會自動幫您改
6. 其他的就檢查看看, JS, postbackurl 有相關需要改的部分

收工.

做研究要避免的21件事

做研究要避免的21件事 - 林盈達教授

I.   Capacity (能力):

    1. Lack of scalability (無法迅速有效地處理大量的件事)
    2. Busy but little throughput (很忙但沒進度)
    3. Crash under heavy load (同時做三件事就掛了)
    4. ON-OFF throughput pattern (間歇性施功)
    5. Brainless and muscleless (不會思考又沒行動力)
    6. Blurred receiver and transmitter (聽不到也講不清重點)
    7. Weak in analysis, organization, or creativity (缺乏分析力組織力創造力)


II.  Attitudes (態度):

    8. Little self-motivation (低度自我期許)
    9. A vacation hen (不專心孵蛋的母雞)
    10. Irregular life style (不規則生活型態)
    11. Messy desktop (混亂的文件與桌面)
    12. A slow coach (慢郎中)
    13. No ideas, no comments, no nothing (腦子一片空白)
    14. Unhealthy personality (不太健康快樂正向的人格)
    15. Too many personal affairs (太多雜事)


III. Disciplines (訓練):

    16. Lack of intensive interaction (缺乏互動腦力激盪)
    17. Pointless discussion (沒有抓住重點的無效討論)
    18. Random walk, no roadmap (做事沒規劃)
    19. Memoryless work planning (做了新的忘了原有的規劃)
    20. Ignorance of details (輕忽細節)
    21. Lack of professionalism (欠缺專業或嚴謹態度)


我想做專案也是一樣吧.