This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / SQL 问题紧急求救!怎么比较两个DATE TYPE IN SQL SERVER
比如,我想找出所有加上10天大于今天的数据:
select *
from test
where inputedate +10 >getdate()
什么涵数能用,谢谢了
-waiting(OK);
2003-1-22
{158}
(#992811@0)
-
use the function dateadd()
-yangn(Raymond);
2003-1-22
(#992840@0)
-
DATEDIFF 也行。
-luoboyang(萝卜秧);
2003-1-22
(#992846@0)
-
对。
-yangn(Raymond);
2003-1-22
(#992854@0)
-
Thanks, i got it, it works well, 大家说说用TEMPOTARY TABLE 好吗?,我需要用这个结果,去和别的表JOIN
just like this
SELECT *
INTO TEMP
FROM testsession
WHERE offeringid IN
(SELECT offeringid
FROM offersession
GROUP BY offeringid
HAVING DATEDIFF(DAY,MAX(enddate),GETDATE())<14)
-waiting(OK);
2003-1-22
{223}
(#992906@0)
-
一点意见。很多developer特别喜欢用temp table,编程省事啊。我的意见是慎用。
1。temp table 要调用tempdb, 从performance上来说, 多余的I/O要用来读temp table 的数据。如果tempdb放在不合适的RAID partition, performance degradation 就更大。
2。如果一定要用temp table,尽量用local 少用global temp table
3.如果你用的是SQL 2000, 建议用table variable instead of temp table, 因为前者用的是system memory, performance 表现要好的多。
-yangn(Raymond);
2003-1-22
{406}
(#992939@0)