Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL SERVER 2005ÖеÄÈÕÆÚʱ¼äÀàÐÍ

 
 
SQL SERVER 2005 ÖеÄÈÕÆÚʱ¼äÀàÐÍ
Ò»£®  Êý¾ÝÀàÐÍ
MS SQL Server 2005 ÓÐ datetime ºÍ smalldatetime Á½ÖÖ¸ñʽµÄÈÕÆÚʱ¼äÊý¾ÝÀàÐÍ¡£×¢Ò⣺ûÓе¥¶ÀµÄÈÕÆÚ»òʱ¼äÀàÐÍ¡£
 
datetime
Êý¾Ý¿âÄÚ²¿ÓÃÁ½¸ö 4 ×Ö½ÚµÄÕûÊý´æ´¢ datetime Êý¾ÝÀàÐ͵ÄÖµ¡£µÚÒ»¸ö 4 ×Ö½Ú´æ´¢»ù´¡ÈÕÆÚ£¨¼´ 1900-1-1, base date £©Ö®Ç°»òÖ®ºóµÄÈÕÆÚ¡£ÈÕÆÚ·¶Î§Îª 1753-1-1 ÖÁ 9999-12-31 ¡£µ±ÈÕÆÚΪ 1900-1-1 ʱֵΪ 0 £»Ö®Ç°µÄÈÕÆÚÊǸºÊý£»Ö®ºóÈÕÆÚÊÇÕýÊý¡£ÁíÍâÒ»¸ö 4 ×Ö½Ú´æ´¢ÒÔÎçÒ¹ºóÈýÓÖÈý·ÖÖ®Ò»£¨ 10/3 £©ºÁÃëÊýËù´ú±íµÄÿÌìµÄʱ¼ä¡£¾«È·¶ÈΪ°Ù·ÖÖ®ÈýÃ루µÈÓÚ 3.33 ºÁÃë»ò 0.00333 Ã룩¡£ÈçϱíËùʾ£¬°ÑÖµµ÷Õûµ½ .000 ¡¢ .003 ¡¢»ò .007 ÃëµÄÔöÁ¿¡£
²éѯÖУ¬ÎÒÃdz£³£ÐèÒªËÑË÷Ö¸¶¨ÈÕÆÚ·¶Î§ÄÚµÄÊý¾Ý£¬±ÈÈç·µ»Ø 1998-01-01 µ±ÌìÄÚµÄÊý¾Ý£¬Äã¿ÉÄÜ»áÕâÑùд£º
Date >= '1998-01-01 00:00:00.000' and date <= '1998-01-01 23:59:59.999'
¸ù¾ÝÉÏÃæµÄµ÷Õû¹æÔò£¬ÆäʵÕâ¾äÓï¾äµÄʵ¼ÊËÑË÷·¶Î§Îª£º
date >= '1998-01-01 00:00:00.000' and date <= '1998-01-02 00:00:00.000'
Äã»á¿´µ½Õâ°üÀ¨ÁË 1998-01-02 µÄÊý¾Ý£¬ËùÒÔ×îºÃµÄÕýÈ·µÄËÑË÷Óï¾äΪ£º
date >= '1998-01-01 00:00:00.000' and date < '1998-01-02 00:00:00.000'
smalldatetime
smalldatetime Êý¾ÝÀàÐÍ´æ´¢ÈÕÆÚºÍÿÌìµÄʱ¼ä£¬µ«¾«È·¶ÈµÍÓÚ datetime ¡£ SQL Server ½« smalldatetime µÄÖµ´æ´¢ÎªÁ½¸ö 2 ×Ö½ÚµÄÕûÊý¡£µÚÒ»¸ö 2 ×Ö½Ú´æ´¢ 1900-1-1 ºóµÄÌìÊý¡£ÁíÍâÒ»¸ö 2 ×Ö½Ú´æ´¢ÎçÒ¹ºóµÄ·ÖÖÓÊý¡£ÈÕÆÚ·¶Î§´Ó 1900-1-1 µ½ 2079-6-6 £¬Ê±¼ä¾«È·µ½·ÖÖÓ¡£ 29.998 Ãë»ò¸üµÍµÄ smalldatetime ÖµÏòÏÂÉáÈëΪ×î½Ó½üµÄ·ÖÖÓ£¬ 29.999 Ãë»ò¸ü¸ßµÄ smalldatetime ÖµÏòÉÏÉáÈëΪ×î½Ó½üµÄ·ÖÖÓ¡£
--returns time as 12:35
SELECT CAST ( '2000-05-08 12:35:29.998' AS smalldatetime )
GO
--returns time as 12:36
SELECT CAST ( '2000-05-08 12:35:29.999' AS smalldatetime )
GO
¶þ£®  ÈÕÆÚʱ¼äµÄ¸³Öµ
ÉÏÃæ˵Á˸ñʽ£¬µ±È»ÎÒÃÇÊÇûÓа취ֱ½Ó¸³ÕûÊý¸øÈÕÆÚʱ¼ä±äÁ¿µÄ¡£¸øÕâЩ±äÁ¿¸³ÖµÍ¨³£ÊǸøËüÖ¸¶¨¸öÒ»¶¨¸ñʽµÄ×Ö·û´®¡£ SQL SERVER »á×Ô¶¯½«×Ö·û´®×ª»»³ÉÈÕÆÚ¸ñʽ±£´æµÄ£¬×¢Ò⣺Êý¾Ý¿âÖÐÊDz»»á±£´æÊý¾Ý¸ñʽµÄ×Ö·û´®µÄ¡£ ÓÐÁ½Àà¸ñʽµÄÈÕÆÚ¸ñʽµÄ×Ö·û´®£¬ SQL SERVER »á·Ç³£ÇáÒ׾͓Èϳö”µÄ¡£
Ò»ÀàÊÇ ISO ʱ¼ä¸ñʽ£¨ÓÉ ISO8601 ¹æ¶¨£©£º yyyy-mm-ddT
hh:mi:ss[.mmm] £¬±


Ïà¹ØÎĵµ£º

sql unionÓ÷¨ºÍsql union allÓ÷¨¼°ËüÃǵÄÔËÐÐЧÂÊ

sql unionÓ÷¨ºÍsql union allÓ÷¨,sql unionЧÂÊ
1¡¢sql unionÓ÷¨
sql unionÔÚ²éѯÖпÉÒÔ½«Á½¸öSQL Óï¾äµÄ½á¹ûºÏ²¢ÆðÀ´¡£Èç¹ûÕâÑù¿´µÄ»°£¬ UNION ¸ú JOIN ÊÇÏàËƵģ¬Á½¸öÖ¸Á¿ÉÒÔÓɶà¸ö±í¸ñÖÐߢȡ×ÊÁÏ¡£
sql unionµÄÒ»¸öÏÞÖÆÊÇÁ½¸ö SQL Óï¾äËù²úÉúµÄÀ¸Î»ÐèÒªÊÇͬÑùµÄ×ÊÁÏÖÖÀà¡£ÁíÍ⣬µ±ÎÒÃÇÓà UNIONÕâ¸öÖ¸Áîʱ£¬Î ......

²»ÖØÆôSQL·þÎñ£¬É¾³ýSQLServerϵͳÈÕÖ¾

    µ±SQLServerµÄϵͳÈÕÖ¾¹ý´ó£¬¾Í»áÒýÆðSQLServer·þÎñÆ÷ÎÞ·¨Æô¶¯µÈһϵÁÐÎÊÌâ¡£½ñÌìÎÒÓöµ½ÁËÕâ¸öÎÊÌ⣬ÔÚÍøÉÏËÑË÷ÁËһϣ¬½â¾ö·½·¨ÊÇɾ³ý¾Í¿ÉÒÔÁË£¬¿ÉÊǵ±Ç°µÄErrorLogÕýÔÚ±»SQLʹÓÃÎÞ·¨É¾³ý°¡£¬ÒªÉ¾³ýÖ»ÄÜÍ£Ö¹SQL·þÎñÆ÷£¬ÄѵÀ¾ÍûÓбðµÃ°ì·¨ÁËÂð£¿
    »Ø´ðÊǿ϶¨µÄ£ºÊ¹ÓÃÒÔÏ´洢¹ý³Ì£º ......

ÐÐÁÐתÖõÄSQLÓï¾ä

ÐÐÁÐתÖõÄSQLÓï¾ä
ÁíÒ»ÖÖÐÐÁÐתÖà -- ¶¯Ì¬ sql ½»²æ±í =========================================================== ×÷Õß: wxy0327(http://wxy0327.itpub.net)
·¢±íÓÚ: 2006.05.10 09:11
·ÖÀà: Oracle
³ö´¦: http://wxy0327.itpub.net/post/16888/88075
-------------------------- ......

SQL Server º¯Êý´óÈ«

SQL Server×Ö·û´®´¦Àíº¯Êý´óÈ«
 selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔ­ÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'Ô ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ