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±äÁ¿ÖУ¬½ö°üº¬µ¥´¿µÄÈÕÆں͵¥
Ïà¹ØÎĵµ£º
1. My test: (create and grant the sysdba to a new user by SQL*Plus)
CREATE USER FJTEST1 IDENTIFIED BY JEANJEANFANG;
GRANT SYSDBA TO FJTEST;
REVOKE SYSDBA from FJTEST;
CONNECT FJTEST1/JEANJEANFANG AS SYSDBA;
2. Using ORAPWD in windows:
C:\» ORAPWD;
(show help information)
3. to see th ......
--> Title : SQL ServerϵͳÊÓͼ
--> Author : wufeng4552
--> Date : 2009-10-28
Ŀ¼ÊÓͼ
Ŀ¼ÊÓͼ·µ»Ø SQL Server Êý¾Ý¿âÒýÇæʹÓõÄÐÅÏ¢¡£½¨ÒéÄúʹÓÃĿ¼ÊÓͼÕâÒ»×î³£ÓõÄĿ¼ԪÊý¾Ý½çÃ棬Ëü¿ÉΪÄúÌṩ×îÓÐЧµÄ·½·¨À´»ñÈ¡¡¢×ª»»²¢ÏÔʾ´ËÐÅÏ¢µÄ×Ô¶¨ÒåÐÎʽ¡£ËùÓÐÓû§¿ÉÓÃĿ¼Ԫ ......
ͨÅä·û_
"_"ºÅ±íʾÈÎÒâµ¥¸ö×Ö·û,¸Ã·ûºÅÖ»ÄÜÆ¥ÅäÒ»¸ö×Ö·û."_"¿ÉÒÔ·ÅÔÚ²éѯÌõ¼þµÄÈÎÒâλÖÃ,ÇÒÖ»ÄÜ´ú±íÒ»¸ö×Ö·û.Ò»¸öºº×ÖֻʹÓÃÒ»¸ö"_"±íʾ.
Àý×Ó£º
if PATINDEX('%[ß¹-×ö]%','ÐèÒªÅжϵÄ×Ö·û')>0 -- ÅжÏÊÇ·ñÓÐ×Ö·û
print 'Óкº×Ö'
else
print 'ÎÞºº×Ö'
ͨÅä·û%
"%"·ûºÅÊÇ×Ö·ûÆ¥Åä·û,ÄÜÆ¥Åä0¸ö»ò¸ü¶à×Ö·ûµÄÈÎÒⳤ¶ ......
ÔÀí£º¶ÔÐèҪȥÖظ´¼Ç¼µÄ×ֶΰ´×éÅÅÐò£¬È»ºóÈ¡ÆäÖÐÒ»Ìõ¼Ç¼¡£ÔÚ×ܲéѯÓï¾äÖÐʹÓÃinÓï·¨¹ýÂË
È¥µôÖظ´¼Ç¼
select * from company where comid in (select Max(comid) from company group by companyname)
µÃµ½Öظ´¼Ç¼Êý
select * from company where comid not in (select Max(comid) from company group by companyn ......
ÒòΪÑöÍûORACLE£¬ËùÒÔÒ»Ö±¶¼ÒÔΪSQL SERVERºÜ±¿¡£
¾Ý´«SQL 2005ÓÐÁËRowIDµÄ¶«Î÷£¬¿ÉÒÔ½â¾öTOPÅÅÐòµÄÎÊÌâ¡£¿Éϧ»¹Ã»Óлú»áÌåÑé¡£ÔÚSQL 2000ÖÐд´æ´¢¹ý³Ì£¬×Ü»áÓöµ½ÐèÒªTOPµÄµØ·½£¬¶øÒ»µ©Óöµ½TOP£¬ÒòΪû°ì·¨°ÑTOPºóÃæµÄÊý×Ö×÷Ϊ±äÁ¿Ð´µ½Ô¤±àÒëµÄÓï¾äÖÐÈ¥£¬ËùÒÔÖ»Äܹ»Ê¹Óù¹Ôì SQL£¬Ê¹ÓÃExecÀ´Ö´ÐС£²»ËµÐ§ÂʵÄÎÊÌ⣠......