在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毫秒。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10294527/viewspace-122662/ ,如需转载,请注明出处,否则将追究法律责任。