Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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]ÑÓ³ÙÖ´ÐÐ


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

¡¾×ª¡¿MySQLÖÐSQLÓÅ»¯ºÍ¼Ü¹¹Éè¼ÆµÄһЩ¼òµ¥Ïë·¨

ÆÕͨMySQLÔËÐУ¬Êý¾ÝÁ¿ºÍ·ÃÎÊÁ¿²»´óµÄ»°£¬ÊÇ×ã¹»¿ìµÄ£¬µ«Êǵ±Êý¾ÝÁ¿ºÍ·ÃÎÊÁ¿¾çÔöµÄʱºò£¬ÄÇô¾Í»áÃ÷ÏÔ·¢ÏÖMySQLºÜÂý£¬ÉõÖÁdownµô£¬ÄÇô¾ÍÒª¿¼ÂÇÓÅ»¯ÎÒÃǵÄMySQLÁË¡£
ÓÅ»¯ÎÞ·ÇÊÇ´ÓÈý¸ö½Ç¶ÈÈëÊÖ£º
µÚÒ»¸öÊÇ´ÓÓ²¼þ£¬Ôö¼ÓÓ²¼þ£¬Ôö¼Ó·þÎñÆ÷
µÚ¶þ¸ö¾ÍÊǶÔÎÒÃǵÄMySQL·þÎñÆ÷½øÐÐÓÅ»¯£¬Ôö¼Ó»º´æ´óС£¬¿ª¶à¶Ë¿Ú£¬¶Áд·Ö¿ª
µÚÈý¸ö ......

SQLÊý¾Ý¿â»¹Ô­Óï¾ä

---¸½¼ÓÊý¾Ý¿â
sp_attach_db   'Êý¾Ý¿âÃû','Êý¾Ý¿âȫ·¾¶','Êý¾Ý¿âÈÕ־ȫ·¾¶'
---²é¿´Êý¾Ý¿âÂß¼­ÎļþÃû
RESTORE FILELISTONLY from disk = '±¸·ÝÎļþ'
---»¹Ô­Êý¾Ý¿â
restore database hzrb from disk = '±¸·ÝÎļþ'
with move 'Ö÷Âß¼­Ãû'     to '´æ·Åmdf·¾¶'    ......

asp.net´Ósql server2005ÖвéѯÊý¾Ý

 Ê×ÏÈÒªÌí¼Ó
using System.Data;
using System.Data.SqlClient;    
½ÓÏÂÀ´£º
          SqlConnection conn = new SqlConnection("server=QLPC\\SQL2005;uid=sa;pwd=£¨ÄãµÄÃÜÂ룩;database=£¨ÄãµÄÊý¾Ý±í£©");     &n ......

½²½â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ºÅ