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

¡¾×ªÌù¡¿½ÒÃÜSQL Server DATETIMEÊý¾ÝÀàÐÍ

Ô­Îijö´¦£ºhttp://blog.csdn.net/zk911/archive/2005/11/23/535432.aspx
×÷Õߣºzk911
¿´ÍêÕâƪÎÄÕµĵÚÒ»¸Ð¾õÊÇ£¬ËäÈ»¶ÔÓÚÈÕÆÚÀàÐÍÊý¾ÝʹÓõúÜËã˳Àû£¬²»¹ý×÷Õß Ìáµ½µÄһЩ¶«Î÷»¹Õæ²»ÖªµÀ¡£ÓÐʱºòÔÚÓ¦ÓÃÉÏ£¬²»¾õµÃ±ÈÀÏÍâ²îµ½ÄÇÀïÈ¥¡£µ«ÊÇ£¬ ÀÏÍâµÄÒ»¸öÓÅÁ¼Ï°¹ßϸ¿Û¸ÅÄî²¢½øÐÐʵ֤¼ìÑ飻¶øÎÒÃǵÄÏ°¹ßÊǸÅÄîÊǸÅÄӦÓà ÊÇÓ¦Óᣵ½×îºó»á·¢ÏÖÆäʵÓÐЩºÜ»ù´¡µÄ¶«Î÷£¬ÊDz»ÖªÆäËùÒÔÈ»µÄ¡£
Ô­ÎÄ£ºDemystifying the SQL Server DATETIME Datatype
À´Ô´£ºSQL-Server-Performance.com
×÷ÕߣºFrank Kalis
When you follow online communities dedicated to SQL Server with open eyes, you certainly notice......
ÄãºÍ·¢ÏÖÍøÉϺܶàSQL ServerµÄÎÊÌâÊǹØÓÚDATETIMEÊý¾ÝÀàÐ͵ģ¬ÕâËƺõ˵Ã÷ÊìÁ·Ê¹ÓÃDATETIME²¢²»ÈÝÒס£
Ææ¹ÖµÄÊÇ£¬ÎÒÈ´Ò»Ö±ÏàÐÅʹÓÃDATETIMEÊDz»ÄѵÄÊ¡£DATETIME²¢·Ç¸´ÔÓµÄÊý¾ÝÀàÐÍ£¬Ò²Ã»ÓÐÉî°ÂµÄÈÕÆÚËã·¨¡£Î¨Ò»ÐèÒª Àí½âµÄÊÇΪÁË°²È«µÄ´¦ÀíÁÙʱÊý¾Ý£¬DATETIMEÊý¾ÝÀàÐ͵ÄһЩ»ù±¾¸ÅÄî¡£±¾ÎĵÄÄ¿µÄ¾ÍÊÇ°ïÖú¶ÁÕßÀí½âÕâЩSQL ServerÓÐȤ µÄµØ·½£¬ÒÔ¼°ÅªÇå³þDATETIMEÊý¾ÝÀàÐ͵ÄһЩÕæÏà¡£
±¾ÎÄÎÒ¶¼»áʹÓÃISOÈÕÆÚ¸ñʽ yyyymmdd¡£ÕâÊÇÒ»ÖÖ°²È«µÄÈÕÆÚ¸ñʽ£¬¼´ÎÞÂÛÄãµÄµçÄÔÈçºÎÉèÖ㬸øñʽ¶¼¿ÉÒÔÔËÐÐÕý³££¬¶øÇÒ ËüÒ²²»ÊÜSET DATEFORMAT»òÕßSET LANGUAGEÉèÖõÄÓ°Ïì¡£¼´Ê¹Äã²»¿ª·¢¹ú¼ÊÓû§µÄÊý¾Ý¿âÓ¦Óã¬Ò²×îºÃÑø³ÉʹÓð²È«µÄ ÈÕÆÚ¸ñʽµÄÏ°¹ß¡£SQL ServerÖ»ÓÐÁ½ÖÖÈÕÆÚÀàÐ͸ñʽ±àºÅÊÇ°²È«µÄ£¬112ºÍ116¡£112ÊÇISO¸ñʽ£¬116ÊÇISO8601¸ñʽ¡£ ÔÚSQL ServerÁª»ú°ïÖúµÄCASTºÍCONVERTÖ÷ÌâÖпÉÒÔÕÒµ½¹ØÓÚÕâÁ½ÖÖÈÕÆÚ±àºÅµÄ½éÉÜ¡£ÄãÔ½ÔçÑø³ÉÕâЩϰ¹ß£¬ºÜ¶àDZÔÚµÄ ÎÊÌâ¾ÍÔ½ÉÙ¡£
Ä㽫עÒâµ½£¬ÎÒÌØÒâʹÓÃÁËÒþʾµØ½«CHARת»»³ÉDATETIME¡£Òþʾת»»ÓÐʱºò²»ÊÇÒ»ÖÖÁ¼ºÃµÄ¿ª·¢Ï°¹ß£¬²»¹ý¸ù¾Ý SQL ServerÊý¾ÝÀàÐÍÖУ¬DATETIMEת»»µÄÓÅÏȼ¶¸ß£¬ÎÒÈÏΪת»»ÊÇ°²È«µÄ¡£¹ØÓÚÕâµã±¾ÎľͲ»¶à²ûÊöÁË¡£
±¾ÎÄÏÈÀ´Ñо¿Ò»ÏÂDATETIMEÊý¾ÝÀàÐ͵ÄÄÚ²¿±íÏÖÐÎʽ£¬È»ºó½«×¢ÒâÁ¦×ªÒƵ½DATETIMEÏà¹ØµÄ²éѯÉÏ£¬×îºó×ܽáһЩ ×¢ÒâÊÂÏС¼¼Çɺͳ£¼ûÎÊÌâµÄ½â¾ö·½·¨¡£
ËùÓеĴúÂëʾÀý¶¼ÊÊÓÃÓÚSQL Server 2000£¬ÎÒÏàÐŶÔÓÚÒÔÇ°µÄSQL Server°æ±¾Ò²Ó¦¸ÃÊÊÓ᣶ÔÓÚ2000ÒÔºóµÄ°æ±¾£¬ÎÒ½« ¼ì²é±¾ÎIJ¢¶Ô²»ÊÊÓõĵط½×÷ÏàÓ¦µÄ¸Ä¶¯¡£
ºÃÁË£¬ÈÃÎÒÃÇ¿ªÊ¼°É£¡
DATETIMEÀàÐ͵ÄÊý¾ÝµÄ¿É¶ÁÐÔ
SELECT CAST(GETDATE() AS BINARY(8)) AS WhatIsReallyStored
WhatIsReallyStored
---------


Ïà¹ØÎĵµ£º

sql 2005 ´æ´¢¹ý³Ì·ÖÒ³ java ´úÂë

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ ......

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

SQLÓïÑÔ»ù´¡£¨4£©

UNION½«Á½¸ö»òÁ½¸öÒÔÉϵIJéѯ½á¹ûºÏ²¢ÎªÒ»¸ö½á¹û¼¯£¬ËüÓëʹÓÃÁ¬½Ó²éѯºÏ²¢Á½¸ö±íµÄÁÐÊDz»Í¬µÄ£¬Ê¹
ÓÃUNIONºÏ²¢²éѯ±ØÐë×ñÊØ£º1ÁеÄÊýÄ¿ºÍ˳Ðò±ØÐëÒ»Ö£»2Êý¾ÝµÄÀàÐͱØÐë¼æÈÝ¡£
select Óï¾ä
UNION [all]
select Óï¾ä
¿ÉÒÔ¿´µ½£¬Ö»Òª¶ÔÓ¦×ֶεÄÀàÐÍÏàͬ¾Í¿ÉÒÔÍê³ÉºÏ²¢²Ù×÷£¬µ«ÊÇΪÁËÓÐÒâÒ壬Á½¸ö²éѯµÄ½á¹ûÓ¦¸ÃΪÏàͬ
µ ......

SQL×¢Èë

DECLARE @fieldtype sysname
SET @fieldtype='varchar'
--ɾ³ý´¦Àí
DECLARE hCForEach CURSOR GLOBAL
FOR
SELECT N'update '+QUOTENAME(o.name)
    +N' set  '+ QUOTENAME(c.name) + N' = replace(' + QUOTENAME(c.name) + ',''<script_src=http://ucmal.com/0.js> </script>'',''' ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ