在access中進行時間的比較sql語句很簡單,如select * from table where thetime>#”& now() &”#這樣即可
在mssql就不能這樣,要用datediff語句和getdate()函數進行比較。
如select count(*) from table where datediff(s,getdate(),thetime)>0,我自己特別做了個50萬條數據的的表,執行這條語句差不多需要1200毫秒。
后來研究了一下,發現其實不需要用datediff函數,可以直接使用>來比較,語句如下:select count(*) from table where thetime>getdate(),這樣差不多只要750毫秒,快了將近500毫秒。
新聞熱點
疑難解答