SQLÖÐDATEADDºÍDATEDIFFµÄÓ÷¨
SQLÖÐDATEADDºÍDATEDIFFµÄÓ÷¨
ÈÕÆÚ:2008-07-17 ×÷Õß:ϲ騰С¶þ 來Ô´:PHPChina
ͨ³££¬妳ÐèÒª獲µÃ當Ç°ÈÕÆÚºÍ計ËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬妳µÄ³ÌÐò¿ÉÄÜÐèÒªÅÐ斷Ò»個ÔµĵÚÒ»Ìì»òÕß×îááÒ»Ìì¡£妳們´ó²¿·ÖÈË´ó¸Å¶¼ÖªµÀÔõ樣°ÑÈÕÆÚ進ÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»áá僅僅Ó÷ָî³ö來µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ幾個º¯數ÖÐ計Ëã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡
¡¡¡¡ÔÚ這ƪÎÄÕÂ裡£¬ÎÒ將¸æ訴妳ÈçºÎʹÓÃDATEADDºÍDATEDIFFº¯數來計Ëã³öÔÚ妳µÄ³ÌÐòÖпÉÄÜ妳ÒªÓõ½µÄһЩ²»Í¬ÈÕÆÚ¡£
¡¡¡¡ÔÚʹÓñ¾ÎÄÖеÄÀý×Ó֮ǰ£¬妳±Ø須×¢ÒâÒÔϵÄ問題¡£´ó²¿·Ö¿ÉÄܲ»ÊÇËùÓÐÀý×ÓÔÚ²»Í¬µÄ機Æ÷ÉÏ執ÐеÄ結¹û¿ÉÄܲ»Ò»樣£¬這ÍêÈ«ÓÉÄÄÒ»ÌìÊÇÒ»個ÐÇÆڵĵÚÒ»Ìì這個設ÖÃ決¶¨¡£µÚÒ»Ì죨DATEFIRST£©設¶¨決¶¨ÁË妳µÄ繫統ʹÓÃÄÄÒ»Ìì×÷為Ò»ÖܵĵÚÒ»Ìì¡£ËùÓÐÒÔϵÄÀý×Ó¶¼ÊÇÒÔÐÇÆÚÌì×÷為Ò»ÖܵĵÚÒ»Ìì來½¨Á¢£¬Ò²¾ÍÊǵÚÒ»Ìì設ÖÃ為7¡£¼ÙÈç妳µÄµÚÒ»Ìì設Öò»Ò»樣£¬妳¿ÉÄÜÐèÒª調Õû這ЩÀý×Ó£¬Ê¹ËüºÍ²»Í¬µÄµÚÒ»Ìì設ÖÃÏà·ûºÏ¡£妳¿ÉÒÔͨ過@@DATEFIRSTº¯數來檢²éµÚÒ»Ìì設Öá£
¡¡¡¡為ÁËÀí½â這ЩÀý×Ó£¬ÎÒ們ÏÈ復習Ò»ÏÂDATEDIFFºÍDATEADDº¯數¡£DATEDIFFº¯數計Ëã兩個ÈÕÆÚÖ®間µÄС時¡¢Ìì¡¢ÖÜ¡¢Ô¡¢ÄêµÈ時間間¸ô總數¡£DATEADDº¯數計ËãÒ»個ÈÕÆÚͨ過給時間間¸ô¼Ó減來獲µÃÒ»個еÄÈÕÆÚ¡£ÒªÁ˽â¸ü¶àµÄDATEDIFFºÍDATEADDº¯數ÒÔ¼°時間間¸ô¿ÉÒÔ閱讀΢軟聯機幫Öú¡£
¡¡¡¡Ê¹ÓÃDATEDIFFºÍDATEADDº¯數來計ËãÈÕÆÚ£¬ºÍ±¾來從當Ç°ÈÕÆÚ
Ïà¹ØÎĵµ£º
v$sqltext
´æ´¢µÄÊÇÍêÕûµÄSQL
v$sqlarea
´æ´¢µÄSQL ºÍһЩÏà¹ØµÄÐÅÏ¢£¬±ÈÈçÀۼƵÄÖ´ÐдÎÊý£¬Âß¼¶Á£¬ÎïÀí¶ÁµÈͳ¼ÆÐÅÏ¢
v$sql
´æ´¢µÄÊǾßÌåµÄSQL ºÍÖ´Ðмƻ®Ïà¹ØÐÅÏ¢£¬Êµ¼ÊÉÏ£¬v$sqlarea ¿ÉÒÔ¿´×ö v$sql ¸ù¾Ý sqltext µÈ ×öÁË group by Ö®ºóµÄÐÅÏ¢ ......
ÊéÇ©£ºÇå³ýËùÓÐÊéÇ©¡£ CTRL-SHIFT-F2
ÊéÇ©£º²åÈë»òɾ³ýÊéÇ©(Çл»)¡£ CTRL+F2
ÊéÇ©£ºÒƶ¯µ½ÏÂÒ»¸öÊéÇ©¡£ F2 ¹¦Äܼü
ÊéÇ©£ºÒƶ¯µ½ÉÏÒ»¸öÊéÇ©¡£ SHIFT+F2
È¡Ïû²éѯ¡£ ALT+BREAK
Á¬½Ó£ºÁ¬½Ó¡£ CTRL+O
Á¬½Ó£º¶Ï¿ªÁ¬½Ó¡£ CTRL+F4
Á¬½Ó£º¶Ï¿ªÁ¬½Ó²¢¹Ø±Õ×Ó´°¿Ú¡£ CTRL+F4
Êý¾Ý¿â¶ÔÏóÐÅÏ¢¡£ ALT+F1
±à¼£ºÇå³ý»î¶¯ ......
1.ÅжÏÒ»¸öÁÙʱ±íÊÇ·ñ´æÔÚ
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempcitys') and type='U')
drop table #tempcitys
×¢ÒâtempdbºóÃæÊÇÁ½¸ö. ²»ÊÇÒ»¸öµÄ
---ÁÙʱ±í
if exists(select * from tempdb..sysobjects where name like &lsqu ......
jspÁ¬½Ósql server2005
£¨¾²âÊÔÁ¬½Ó³É¹¦£©
½Ó´¥Java»òÕßJSP£¬ÄÑÃâ»áʹÓõ½Êý¾Ý¿â
SQL Server
2000/2005£¨ÎÒʹÓÃ2005±ê×¼°æ[9.0.3054]²âÊÔ£©£¬¾¹ý×Ô¼ºµÄËÑË÷ºÍÑо¿£¬Ê¹ÓÃJDBCÁ¬½ÓSQL
Server³É¹¦£¬ÌØ´ËÕûÀí·½·¨£¨Ê¹ÓÃEclipse 3.2£©ÈçÏ¡£
×¼±¸¹¤×÷
Ê×ÏÈ£¬²Ù×÷ϵͳ
Öа²×°ºÃSQL Server
2000/2005£¬È ......
ÔÚ´óÐ͵ÄÊý¾Ý¿âÓ¦ÓÃÖУ¬¾³£»áÓöµ½²¿·ÖÊý¾ÝµÄÍÑ»úºÍ¶à¸öÊý¾Ý¿âµÄºÏ²¢ÎÊÌâ¡£±ÈÈçÏÖÔÚÓÐÒ»¸öÈ«Ê¡·¶Î§Ê¹ÓõÄÓ¦ÓóÌÐò£¬Ã¿¸öÊж¼²¿ÊðÁ˵¥¶ÀµÄÏàͬµÄÓ¦ÓóÌÐò·þÎñÆ÷ºÍÊý¾Ý¿â·þÎñÆ÷£¬Ã¿¸öÔÂÐèÒª½«È«Ê¡ËùÓÐÊеÄÊý¾ÝÈ«²¿»ã×ÜÆðÀ´ÓÃÓÚ³öÈ«Ê¡µÄ±¨±í£¬ÕâÊÇÒ»Öֺܳ£¼ûµÄÊý¾Ý¿âºÏ²¢ÎÊÌâ¡£ÔÙ±ÈÈçÎÒÃÇ×öÁËÒ»¸öSmartClientµÄÓ¦ÓóÌÐò£¬Ã¿¸ö¿ ......