sql DATEPART£¨£©º¯Êý
cdateÊÇdatetimeÀàÐ͵Ä×Ö¶Î
ͳ¼ÆÒ»ÄêµÄÈçÏÂ
select datepart(yy,cdate) as 'Ô·Ý',sum(cmoney) from consumption group by datepart(yy,cdate)
ͳ¼ÆÒ»ÔµÄÈçÏÂ
select datepart(mm,cdate) as 'Ô·Ý',sum(cmoney) from consumption where datepart(yy,cdate)=2009 group by datepart(mm,cdate)
ͳ¼ÆÒ»ÖܵÄÈçÏÂ
select DATEPART(wk,cdate) as 'ÖÜ', sum(cmoney) from consumption group by DATEPART(wk,cdate)
ͳ¼ÆÒ»ÌìµÄÈçÏÂ
select DATEPART(dd,cdate) as 'ºÅ', sum(cmoney) from consumption where datepart(mm,cdate)=6 group by DATEPART(dd,cdate)
ÒÔÉÏÓõ½µÄ¾ÍÊÇ“DATEPART£¨£©”º¯Êý¡£º¯ÊýDATEPART£¨£©µÄ²ÎÊýÊÇÁ½¸ö±äÁ¿¡£µÚÒ»¸ö±äÁ¿Ö¸¶¨Òª³éÈ¡ÈÕÆÚµÄÄÄÒ»²¿·Ö£»µÚ¶þ¸ö±äÁ¿ÊÇʵ¼ÊµÄÊý¾Ý¡£
ÈÕÆÚµÄ¸÷²¿·Ö¼°Æä¼òд
ÈÕÆÚ²¿·Ö ¼òд Öµ
year yy 1753--9999
quarter qq 1--4
month mm 1--12
day of year dy 1--366
day dd 1--31
week wk &n
Ïà¹ØÎĵµ£º
ÕâÁ½Ììдһ¸öºÍͳ¼ÆÊý¾ÝÓйصĴ洢¹ý³Ì£¬ÀïÃæÒªÀûÓÃÈÕÆÚ½øÐÐһЩ¼ÆËãºÍÅжϣ¬Ò²×ÔȻҪÀûÓÃSQLµÄһЩÈÕÆÚÏà¹ØµÄº¯Êý¡£ÕâÀïÂÔ¼Çһϣ¬µ±ÊǸ´Ï°Ò»ÏÂSQL¡£
ÀûÓÃSQL½Å±¾ÄÚÖõöº¯Êý£¬ÎÒÃÇÄÜÁé»îµÄ¶ÔÈÕÆÚ½øÐмÆËãºÍ±È½Ï¡£³£Óõöº¯Êý£ºGETDATE(),DATEDIFF(),DATEADD()
GETDATE() µ±È»¹ËÃû˼Ò壬µÃµ½µ±Ç°µÄÈÕÆÚ£¬·µ»ØÀàÐÍÊ ......
ÎÒÃÇÔÚ±àдMISϵͳºÍWebÓ¦ÓóÌÐòµÈϵͳʱ£¬¶¼Éæ¼°µ½ÓëÊý¾Ý¿âµÄ½»»¥£¬Èç¹ûÊý¾Ý¿âÖÐÊý¾ÝÁ¿ºÜ´óµÄ»°£¬Ò»´Î¼ìË÷ËùÓеļǼ£¬»áÕ¼ÓÃϵͳºÜ´óµÄ×ÊÔ´£¬Òò´ËÎÒÃdz£³£²ÉÓã¬ÐèÒª¶àÉÙÊý¾Ý¾ÍÖ»´ÓÊý¾Ý¿âÖÐÈ¡¶àÉÙÌõ¼Ç¼£¬¼´²ÉÓ÷ÖÒ³Óï¾ä¡£¸ù¾Ý×Ô¼ºÊ¹ÓùýµÄÄÚÈÝ£¬°Ñ³£¼ûÊý¾Ý¿âSQL Server,OracleºÍMySQLµÄ·ÖÒ³Óï¾ä£¬´ÓÊý¾Ý¿â±íÖÐµÄµÚ ......
參¿¼: http://brightsky006.blog.163.com/blog/static/22583668200962195059485/
°ÑSQL 2005µÄ±¸·ÝÎļþµ¼Èëµ½SQL 2000
ѧϰÕ䲨 2009-07-21 09:50 ÔĶÁ616 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
µçÄÔÉϰ²×°ÁËSQL Server 2005£¬ÏÖÔÚÏë»»»ØSQL2000À´£¬ ......
ÕýÔÚ¼ÓÔØÊý¾Ý...
¡¡¡¡1.°´ÐÕÊϱʻÅÅÐò: select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
¡¡¡¡2.Êý¾Ý¿â¼ÓÃÜ: select encrypt(’ÔʼÃÜÂë’) select pwdencrypt(’ÔʼÃÜÂë’) select pwdcompare(’ÔʼÃÜÂë’,’¼ÓÃܺóÃÜÂë’) = 1--Ïàͬ£»·ñÔ ......
Ò»¡¢ÈçºÎ¶¯Ì¬´´½¨Óû§
1.ʹÓô洢¹ý³Ì
sp_addlogin (Transact-SQL)
´´½¨Ð嵀 SQL Server µÇ¼£¬¸ÃµÇ¼ÔÊÐíÓû§Ê¹Óà SQL Server Éí·ÝÑéÖ¤Á¬½Óµ½ SQL Server ʵÀý¡£
ÖØÒªÌáʾ£º
ºóÐø°æ±¾µÄ Microsoft SQL Server ½«É¾³ý¸Ã¹¦ÄÜ¡£Çë±ÜÃâÔÚеĿª·¢¹¤×÷ÖÐʹÓøù¦ÄÜ£¬²¢×ÅÊÖÐ޸ĵ±Ç°»¹ÔÚʹÓøù¦ÄܵÄÓ¦ÓóÌÐò¡£Çë¸ÄÓà CREAT ......