Sqlserver中時間查詢的一個比較快的語句

Sqlserver中時間查詢的一個比較快的語句,第1張

Sqlserver中時間查詢的一個比較快的語句,第2張

access sql語句中比較時間很簡單,比如select * from table where time > #" & now()&" #,這樣就可以
not in mssql。應該用datediff語句和getdate()函數比較一下。

比如select count(*)from table where datediff(s,getdate(),the time) >0,我特意做了一個有50萬數據的表,執行這個語句差不多要1200ms。

後來研究了一下,發現不需要用datediff函數,可以用>直接比較。語句如下:select count(*)from table where time >getdate(),耗時將近750毫秒,快了將近500毫秒。

位律師廻複

生活常識_百科知識_各類知識大全»Sqlserver中時間查詢的一個比較快的語句

0條評論

    發表評論

    提供最優質的資源集郃

    立即查看了解詳情