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

SQL ServerÈÕÆÚ´¦ÀídatetimeºÍdateÖ®¼äµÄÏ໥ת»»

 
ÈÕÆÚÀàÐ͸ÅÊö
SQL ServerÖеÄÈÕÆÚÀàÐÍ°üÀ¨datetimeºÍsmalldatetime£¬½öÄÜ´¦Àí¿ÉÒÔʶ±ðΪ1753Äê¡«9999Äê¼äµÄÈÕÆÚµÄÖµ£¬Ã»Óе¥¶ÀµÄÈÕÆÚÐÍ»òʱ¼äÐÍ¡£
1£®datetime
datetimeÀàÐÍ´¦Àí´Ó1753Äê1ÔÂ1ÈÕ¡«9999Äê12ÔÂ31ÈÕµÄÈÕÆÚºÍʱ¼äÊý¾Ý£¬¾«È·¶ÈΪ°Ù·ÖÖ®ÈýÃë¡£
¼´£º¶ÔÓÚ0.000¡«0.001¡¢0.009µÄÈÕÆÚÖµ£¬µ÷ÕûΪ0.000£»¶ÔÓÚ0.002¡«0.004µÄÈÕÆÚÖµ£¬µ÷ÕûΪ0.003£»¶ÔÓÚ
0.005¡«0.008µÄÈÕÆÚÖµ£¬µ÷ÕûΪ0.007¡£
ÀýÈ磬ÏÂÃæµÄ´úÂëÔÚÊäÈëʱ£¬Æäʱ¼ä¾«È·¶ÈΪ°Ù·ÖÖ®Ò»Ã룬µ«¾­Êý¾Ý¿â±£´æºóÔÙÏÔʾ³öÀ´£¬Æä½á¹û¾ÍÒѾ­×öÁË´¦Àí¡£
DECLARE @t TABLE(date char(21))
INSERT @t SELECT '1900-1-1 00:00:00.000'
...
INSERT @t SELECT '1900-1-1 00:00:00.009'
SELECT date,ת»»ºóµÄÈÕÆÚ=CAST(date as datetime) from @t
/*--½á¹û
date                     ת»»ºóµÄÈÕÆÚ
---------------------------------- ----------------------------
1900-1-1 00:00:00.000    1900-01-01 00:00:00.000
...
1900-1-1 00:00:00.000    1900-01-01 00:00:00.010
--*/
datetimeµÄ´æ´¢³¤¶ÈΪ8×Ö½Ú£¬ÈÕÆÚºÍʱ¼ä¸÷ÓÃ4¸ö×Ö½Ú´æ´¢£¬µÚÒ»¸ö4×Ö½Ú´æ´¢×Ô1900Äê1ÔÂ1ÈÕ֮ǰ»òÖ®
ºóµÄÌìÊý£¨ÒÔ1900Äê1ÔÂ1ÈÕΪ·Ö½çµã£¬ÔÚ1900Äê1ÔÂ1ÈÕ֮ǰµÄÈÕÆÚµÄÌìÊýСÓÚ0£¬ÔÚ1900Äê1ÔÂ1ÈÕÖ®ºóµÄÈÕÆÚµÄÌìÊý´óÓÚ0£©¡£ÁíÍâÒ»¸ö4×Ö½Ú
´æ´¢ÒÔÎçÒ¹£¨00:00:00.000£©ºóºÁÃëÊýËù´ú±íµÄÿÌìµÄʱ¼ä¡£
ÀýÈ磬ÏÂÃæµÄ´úÂëÑÝʾÁËdatetime±äÁ¿ÖУ¬½ö°üº¬µ¥´¿µÄÈÕÆں͵¥´¿µÄʱ¼äʱ£¬ÈÕÆÚ´æ´¢µÄÊ®Áù½øÖÆ´æ´¢±íʾ½á¹û¡£
DECLARE @dt datetime
--µ¥´¿µÄÈÕÆÚ
SET @dt='1900-1-2'
SELECT CAST(@dt as binary(8))
--½á¹û: 0x0000000100000000
--µ¥´¿µÄʱ¼ä
SET @dt='00:00:01'
SELECT CAST(@dt as binary(8))
--½á¹û: 0x000000000000012C
2£®smalldatetime
smalldatetimeÀàÐÍ´¦Àí´Ó1900Äê1ÔÂ1ÈÕ¡«2079Äê6ÔÂ6 ÈÕµÄÈÕÆÚºÍʱ¼äÊý¾Ý£¬¾«È·µ½·ÖÖÓ¡£29.998Ãë»ò¸üµÍµÄsmalldatetimeÖµÏòÏÂÉáÈëΪ×î½Ó½üµÄ·ÖÖÓ£¬29.999Ãë»ò¸ü¸ßµÄsmalldatetimeÖµÏòÉÏÉáÈëΪ×î½Ó½üµÄ·ÖÖÓ¡£
smalldatetimeµÄ´æ´¢³¤¶ÈΪ4×Ö½Ú£¬µÚÒ»¸ö2×Ö½Ú´æ´¢×Ô1900Äê1ÔÂ1ÈÕÖ®ºóµÄÌìÊý¡£ÁíÍâÒ»¸ö2×Ö½Ú´æ´¢ÎçÒ¹£¨00:00:00.000£©ºóµÄ·ÖÖÓÊý¡£
ÀýÈ磬ÏÂÃæµÄ´úÂëÑÝʾÁËsmalldatetime±äÁ¿ÖУ¬½ö°üº¬µ¥´¿µÄÈÕÆں͵¥


Ïà¹ØÎĵµ£º

SQL ServerϵͳÊÓͼ


--> Title  : SQL ServerϵͳÊÓͼ
--> Author : wufeng4552
--> Date   : 2009-10-28
 
Ŀ¼ÊÓͼ
Ŀ¼ÊÓͼ·µ»Ø SQL Server Êý¾Ý¿âÒýÇæʹÓõÄÐÅÏ¢¡£½¨ÒéÄúʹÓÃĿ¼ÊÓͼÕâÒ»×î³£ÓõÄĿ¼ԪÊý¾Ý½çÃ棬Ëü¿ÉΪÄúÌṩ×îÓÐЧµÄ·½·¨À´»ñÈ¡¡¢×ª»»²¢ÏÔʾ´ËÐÅÏ¢µÄ×Ô¶¨ÒåÐÎʽ¡£ËùÓÐÓû§¿ÉÓÃĿ¼Ԫ ......

[SQL Server]ÑÓ³ÙÖ´ÐÐ


WAITFOR
Ö¸¶¨´¥·¢Óï¾ä¿é¡¢´æ´¢¹ý³Ì»òÊÂÎñÖ´ÐеÄʱ¼ä¡¢Ê±¼ä¼ä¸ô»òʼþ¡£
Óï·¨
WAITFOR { DELAY 'time' | TIME
'time' }
²ÎÊý
DELAY
ָʾ Microsoft® SQL Server™ Ò»Ö±µÈµ½Ö¸¶¨µÄʱ¼ä¹ýÈ¥£¬×¿É´ï 24 Сʱ¡£
'time'
ÒªµÈ´ýµÄʱ¼ä¡£¿ÉÒÔ°´ datetime Êý¾Ý¿É½ÓÊܵĸñʽָ¶¨
time£¬Ò²¿ÉÒÔÓþֲ¿±äÁ¿Ö¸¶ ......

SQL*Plus ÖеÄspoolʹÓ÷½·¨

 ÔÚʹÓÃSQL*PlusÉú³É±¨¸æÎļþµÄʱºò£¬ÍùÍù»áÒòΪÆäĬÈϵÄÉèÖõ¼ÖÂÊä³öµÄ½á¹û·Ç³£µÄûÓпɶÁÐÔ£¬ÏÂÃæ½éÉÜÒ»¸öÈÕ³£ÖлᱻÓõ½µÄÒ»¸ö½Å±¾£¬ÆäÖаüº¬Ò»Ð©¸ñʽ»¯
Êä³öµÄsetÃüÁî
£¬ÎªÁË·½±ãÀí½â£¬ÎÒ»áÔÚÿһÌõsetÃüÁîÖ®ºó½ô¸ú×ÅÒ»¸ö¼òµ¥µÄ½âÊÍ£¬ÇëÂýÂýÌå»á¡£
sqlplus -s user_name/user_password << EOF >/dev/n ......

SQL SERVERµÄROWCOUNT¹Ø¼ü×Ö

 
ÒòΪÑöÍûORACLE£¬ËùÒÔÒ»Ö±¶¼ÒÔΪSQL SERVERºÜ±¿¡£
¾Ý´«SQL 2005ÓÐÁËRowIDµÄ¶«Î÷£¬¿ÉÒÔ½â¾öTOPÅÅÐòµÄÎÊÌâ¡£¿Éϧ»¹Ã»Óлú»áÌåÑé¡£ÔÚSQL 2000ÖÐд´æ´¢¹ý³Ì£¬×Ü»áÓöµ½ÐèÒªTOPµÄµØ·½£¬¶øÒ»µ©Óöµ½TOP£¬ÒòΪû°ì·¨°ÑTOPºóÃæµÄÊý×Ö×÷Ϊ±äÁ¿Ð´µ½Ô¤±àÒëµÄÓï¾äÖÐÈ¥£¬ËùÒÔÖ»Äܹ»Ê¹Óù¹Ôì SQL£¬Ê¹ÓÃExecÀ´Ö´ÐС£²»ËµÐ§ÂʵÄÎÊÌ⣠......

½²½âSQL ServerÖÐÈÝÒ×»ìÏýµÄÊý¾ÝÀàÐÍ


½²½âSQL ServerÖÐÈÝÒ×»ìÏýµÄÊý¾ÝÀàÐÍ
(1)char¡¢varchar¡¢textºÍnchar¡¢nvarchar¡¢ntext 
¡¡¡¡charºÍvarcharµÄ³¤¶È¶¼ÔÚ1µ½8000Ö®¼ä£¬ËüÃǵÄÇø±ðÔÚÓÚcharÊǶ¨³¤×Ö·ûÊý¾Ý£¬¶øvarcharÊDZ䳤×Ö·ûÊý¾Ý¡£Ëùν¶¨³¤¾ÍÊdz¤¶È¹Ì¶¨µÄ£¬µ±ÊäÈëµÄÊý¾Ý³¤¶ÈûÓдﵽָ¶¨µÄ³¤¶Èʱ½«×Ô¶¯ÒÔÓ¢ÎÄ¿Õ¸ñÔÚÆäºóÃæÌî³ä£¬Ê¹³¤¶È´ïµ½ÏàÓ¦ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ