SQLÖÐDATEADDºÍDATEDIFFµÄÓ÷¨
¹Ì¶¨ÈÕÆÚ¼õÒ»¸öÔ£¨ÈÕ¡¢Ä꣩
dateadd(±í´ïʽ1£¬±í´ïʽ2£¬±í´ïʽ3£©
±í´ïʽ1ΪMM»òYY»òDD
±í´ïʽ2Ϊ1
±í´ïʽ3ΪҪ¼õµÄÈÕÆÚ Ò»¸öÔµĵÚÒ»Ìì µÚÒ»¸öÀý×Ó£¬ÎÒ½«¸æËßÄãÈçºÎ´Óµ±Ç°ÈÕÆÚÈ¥Õâ¸öÔµÄ×îºóÒ»Ìì¡£Çë×¢Ò⣺Õâ¸öÀý×ÓÒÔ¼°ÕâƪÎÄÕÂÖеÄÆäËûÀý×Ó¶¼½«Ö»Ê¹ÓÃDATEDIFFºÍDATEADDº¯ÊýÀ´¼ÆËãÎÒÃÇÏëÒªµÄÈÕÆÚ¡£Ã¿Ò»¸öÀý×Ó¶¼½«Í¨¹ý¼ÆË㵫ǰµÄʱ¼ä¼ä¸ô£¬È»ºó½øÐмӼõÀ´µÃµ½ÏëÒª¼ÆËãµÄÈÕÆÚ¡£ ÕâÊǼÆËãÒ»¸öÔµÚÒ»ÌìµÄSQL ½Å±¾£º Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) ÎÒÃÇ°ÑÕâ¸öÓï¾ä·Ö¿ªÀ´¿´¿´ËüÊÇÈçºÎ¹¤×÷µÄ¡£×îºËÐĵĺ¯ÊýÊÇgetdate()£¬´ó²¿·ÖÈ˶¼ÖªµÀÕâ¸öÊÇ·µ»Øµ±Ç°µÄÈÕÆÚºÍʱ¼äµÄº¯Êý¡£ÏÂÒ»¸öÖ´Ðеĺ¯ÊýDATEDIFF(mm,0,getdate())ÊǼÆË㵱ǰÈÕÆں͡°1900-01-01 00:00:00.000¡±Õâ¸öÈÕÆÚÖ®¼äµÄÔÂÊý¡£¼Çס£ºÊ±ÆÚºÍʱ¼ä±äÁ¿ºÍºÁÃëÒ»ÑùÊÇ´Ó¡°1900-01-01 00:00:00.000¡±¿ªÊ¼¼ÆËãµÄ¡£Õâ¾ÍÊÇΪʲôÄã¿ÉÒÔÔÚDATEDIFFº¯ÊýÖÐÖ¸¶¨µÚÒ»¸öʱ¼ä±í´ïʽΪ¡°0¡±¡£ÏÂÒ»¸öº¯ÊýÊÇDATEADD£¬Ôö¼Óµ±Ç°ÈÕÆÚµ½¡°1900-01-01¡±µÄÔÂÊý¡£Í¨¹ýÔö¼ÓÔ¤¶¨ÒåµÄÈÕÆÚ¡°1900-01-01¡±ºÍµ±Ç°ÈÕÆÚµÄÔÂÊý£¬ÎÒÃÇ¿ÉÒÔ»ñµÃÕâ¸öÔµĵÚÒ»Ìì¡£ÁíÍ⣬¼ÆËã³öÀ´µÄÈÕÆÚµÄʱ¼ä²¿·Ö½«»áÊÇ¡°00:00:00.000¡±¡£ Õâ¸ö¼ÆËãµÄ¼¼ÇÉÊÇÏȼÆË㵱ǰÈÕÆÚµ½¡°1900-01-01¡±µÄʱ¼ä¼ä¸ôÊý£¬È»ºó°ÑËü¼Óµ½¡°1900-01-01¡±ÉÏÀ´»ñµÃÌØÊâµÄÈÕÆÚ£¬Õâ¸ö¼¼ÇÉ¿ÉÒÔÓÃÀ´¼ÆËãºÜ¶à²»Í¬µÄÈÕÆÚ¡£ÏÂÒ»¸öÀý×ÓÒ²ÊÇÓÃÕâ¸ö¼¼ÇÉ´Óµ±Ç°ÈÕÆÚÀ´²úÉú²»Í¬µÄÈÕÆÚ¡£ ±¾ÖܵÄÐÇÆÚÒ» ÕâÀïÎÒÊÇÓÃÖÜ(wk)µÄʱ¼ä¼ä¸ôÀ´¼ÆËãÄÄÒ»ÌìÊDZ¾ÖܵÄÐÇÆÚÒ»¡£ Select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0) Ò»ÄêµÄµÚÒ»Ìì ÏÖÔÚÓÃÄê(yy)µÄʱ¼ä¼ä¸ôÀ´ÏÔʾÕâÒ»ÄêµÄµÚÒ»Ìì¡£ Select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0) ¼¾¶ÈµÄµÚÒ»Ìì ¼ÙÈçÄãÒª¼ÆËãÕâ¸ö¼¾¶ÈµÄµÚÒ»Ì죬Õâ¸öÀý×Ó¸æËßÄã¸ÃÈçºÎ×ö¡£ Select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0) µ±ÌìµÄ°ëÒ¹ Ôø¾ÐèҪͨ¹ýgetdate()º¯ÊýΪÁË·µ»Øʱ¼äÖµ½Øµôʱ¼ä²¿·Ö£¬¾Í»á¿¼Âǵ½µ±Ç°ÈÕÆÚÊDz»ÊÇÔÚ°ëÒ¹¡£¼ÙÈçÕâÑù£¬Õâ¸öÀý×ÓʹÓÃDATEDIFFºÍDATEADDº¯ÊýÀ´»ñµÃ°ëÒ¹µÄʱ¼äµã¡£ Select DATEADD(dd, DATEDIFF(dd,0,getdate()), 0) ÉîÈëDATEDIFFºÍDATEADDº¯Êý¼ÆËã Äã¿ÉÒÔÃ÷°×£¬Í¨¹ýʹÓüòµ¥µÄDATEDIFFºÍDATEADDº¯Êý¼ÆË㣬Äã¿ÉÒÔ·¢Ïֺܶ಻ͬµÄ¿ÉÄÜÓÐÒâÒåµÄÈÕÆÚ¡£ ĿǰΪֹµÄËùÓÐÀý×ÓÖ»Êǽö½ö¼ÆË㵱ǰµÄʱ¼äºÍ¡°1900-01-01¡±Ö®¼äµÄʱ¼ä¼ä¸ôÊýÁ¿£¬È»ºó°ÑËü¼Óµ½¡°1900-01-01¡±µÄʱ¼ä¼ä¸ôÉÏÀ´
Ïà¹ØÎĵµ£º
ORACLEÊý¾Ý¿âÀï±íµ¼ÈëSQL ServerÊý¾Ý¿â
1¡¢ÔÚÄ¿µÄSQL ServerÊý¾Ý¿â·þÎñÆ÷ÉÏ°²×°ORACLE ClientÈí¼þ»òÕßORACLE ODBC Driver.
ÔÚ$ORACLE_HOME\network\admin\tnsnames.oraÀïÅäÖÃORACLEÊý¾Ý¿âµÄ±ðÃû(service name)¡£
2¡¢ÔÚWIN2000»òÕßwin200 ......
µÚÒ»ÖÖ£º
public void deleteUser(String byemail) {
Session session = getSession();
Transaction transaction = null;
String hql = "delete from Register where email=?
";
try {
transaction = session.beginTransactio ......
Ò»¡¢Ê¹ÓòÎÊý»¯ÊäÈë¡£´æ´¢¹ý³ÌÀᄀÁ¿±ÜÃâÓï¾äÆ´½Ó¡£
¶þ¡¢¶ÔÓÚһЩÊý¾Ý¿â£¬±ØÐëÉèÖÃȨÏÞ£¬ÉõÖÁÉèÖõ½×ֶΡ£
Èý¡¢Ê¼ÖÕͨ¹ý²âÊÔÀàÐÍ¡¢³¤¶È¡¢¸ñʽºÍ·¶Î§À´ÑéÖ¤Óû§ÊäÈë¡£
ËÄ¡¢¹ýÂËÃô¸Ð×Ö·û¡£
Function ReplaceStr(Str)
Str=Trim(Str)
Str=Replace(Str,"'","'")
Str=Replace(Str,";",";")
Str=Rep ......
--> Title : SQL Server2005 SynonymµÄʹÓÃ
--> Author : wufeng4552
--> Date : 2009-10-30
1.SynonymµÄ¸ÅÄî
¡¡ Synonym£¨Í¬Òå´Ê£©ÊÇSQL Server 2005µÄÐÂÌØÐÔ¡£¿ÉÒÔ¼òµ¥µÄÀí½âSynonymΪÆäËû對ÏóµÄ±ðÃû¡£
語·¨
CREATE SYNONYM [ schema_name_1. ] synonym_name FOR & ......
1.Óà CUBE »ã×ÜÊý¾Ý
CUBE ÔËËã·ûÉú³ÉµÄ½á¹û¼¯ÊǶàάÊý¾Ý¼¯¡£¶àάÊý¾Ý¼¯ÊÇÊÂʵÊý¾ÝµÄÀ©Õ¹£¬ÊÂʵÊý¾Ý¼´¼Ç¼¸ö±ðʼþµÄÊý¾Ý¡£À©Õ¹½¨Á¢ÔÚÓû§´òËã·ÖÎöµÄÁÐÉÏ¡£ÕâЩÁб»³ÆΪά¡£¶àάÊý¾Ý¼¯ÊÇÒ»¸ö½á¹û¼¯£¬ÆäÖаüº¬Á˸÷ά¶ÈµÄËùÓпÉÄÜ×éºÏµÄ½»²æ±í¸ñ¡£ CUBE ÔËËã·ûÔÚ SELECT Óï¾äµÄ GROUP BY ×Ó¾äÖÐÖ¸¶¨¡£¸ÃÓï¾äµÄÑ¡ÔñÁбíÓ ......