Sql ServerÖеÄÈÕÆÚÓëʱ¼äº¯Êý
1. µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
select getdate()
2. dateadd ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
select dateadd(day,2,'2004-10-15') --·µ»Ø£º2004-10-17 00:00:00.000
3. datediff ·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£
select datediff(day,'2004-09-01','2004-09-18') --·µ»Ø£º17
4. datepart ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊý¡£
SELECT DATEPART(month, '2004-10-15') --·µ»Ø 10
5. datename ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®
SELECT datename(weekday, '2004-10-15') --·µ»Ø£ºÐÇÆÚÎå
6. day(), month(),year() --¿ÉÒÔÓëdatepart¶ÔÕÕÒ»ÏÂ
select µ±Ç°ÈÕÆÚ=convert(varchar(10),getdate(),120)
,µ±Ç°Ê±¼ä=convert(varchar(8),getdate(),114)
select datename(dw,'2004-10-15')
select ±¾ÄêµÚ¶àÉÙÖÜ=datename(week,'2004-10-15')
,½ñÌìÊÇÖܼ¸=datename(weekday,'2004-10-15')
º¯Êý
²ÎÊý/¹¦ÄÜ
GetDate( )
·µ»ØÏµÍ³Ä¿Ç°µÄÈÕÆÚÓëʱ¼ä
DateDiff (interval,date1,date2)
ÒÔinterval Ö¸¶¨µÄ·½Ê½£¬·µ»Ødate2 Óëdate1Á½¸öÈÕÆÚÖ®¼äµÄ²îÖµ date2-date1
DateAdd (interval,number,date)
ÒÔintervalÖ¸¶¨µÄ·½Ê½£¬¼ÓÉÏnumberÖ®ºóµÄÈÕÆÚ
DatePart (interval,date)
·µ»ØÈÕÆÚdateÖУ¬intervalÖ¸¶¨²¿·ÖËù¶ÔÓ¦µÄÕûÊýÖµ
DateName (interval,date)
·µ»ØÈÕÆÚdateÖУ¬intervalÖ¸¶¨²¿·ÖËù¶ÔÓ¦µÄ×Ö·û´®Ãû³Æ
²ÎÊý intervalµÄÉ趨ֵÈçÏ£º
Öµ
Ëõ д£¨Sql Server£©
Access ºÍ ASP
˵Ã÷
Year
Yy
yyyy
Äê 1753 ~ 9999
Quarter
Qq
q
¼¾ 1 ~ 4
Month
Mm
m
ÔÂ1 ~ 12
Day of year
Dy
y
Ò»ÄêµÄÈÕÊý,Ò»ÄêÖеĵڼ¸ÈÕ 1-366
Day
Dd
d
ÈÕ£¬1-31
Weekday
Dw
w
Ò»ÖܵÄÈÕÊý£¬Ò»ÖÜÖеĵڼ¸ÈÕ 1-7
Week
Wk
ww
ÖÜ£¬Ò»ÄêÖеĵڼ¸ÖÜ 0 ~ 51
Hour
Hh
h&nbs
Ïà¹ØÎĵµ£º
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......
/*
½¨±í£º
dept:
deptno(primary key),dname,loc
emp:
empno(primary key),ename,job,mgr,sal,deptno
*/
1 Áгöemp±íÖи÷²¿ÃŵIJ¿Ãźţ¬×î¸ß¹¤×Ê£¬×îµÍ¹¤×Ê
select max(sal) as ×î¸ß¹¤×Ê,min(sal) as ×îµÍ¹¤×Ê,deptno from emp group by deptno;
2 Áгöemp±íÖи÷²¿ÃÅjobΪ'CLERK'µÄÔ±¹¤µÄ×îµÍ¹¤×Ê£¬×î¸ß¹¤×Ê
sele ......
The following is improved version of the code created by David Mullet, from
http://rubyonwindows.blogspot.com/2007/03/ruby-ado-and-sqlserver.html
require 'win32ole'
class SqlServer
# This class manages database connection and queries
attr_accessor :connection, :data, :fields
attr_wr ......
SQL ServerÊý¾Ý²Ö¿âÏà¹Ø¸ÅÄî-ά¶È±íºÍÊÂʵ±í¸ÅÊö ÊÕ²Ø
¿ªÊ¼Ñо¿BI£¬³õѧ¡£»á¼Ç¼һЩ¸ÅÄîÐÔµÄÎÄÕ¡£
»ù±¾¸ÅÄ
1.¶àάÊý¾Ý¼¯£º¶àάÊý¾Ý¼¯ÊÇÁª»ú·ÖÎö´¦Àí (OLAP) ÖеÄÖ÷Òª¶ÔÏó£¬ÊÇÒ»Ïî¿É¶ÔÊý¾Ý²Ö¿âÖеÄÊý¾Ý½øÐпìËÙ·ÃÎʵļ¼Êõ¡£¶àάÊý¾Ý¼¯ÊÇÒ»¸öÊý¾Ý¼¯ºÏ£¬Í¨³£´ÓÊý¾Ý²Ö¿âµÄ×Ó¼¯¹¹Ô죬²¢×éÖ¯ºÍ»ã×ܳÉÒ»¸öÓÉÒ»×éά¶ÈºÍ¶ÈÁ ......
ÎÒÃÇÔÚ¿ª·¢¹ý³ÌÖУ¬¾³£Óöµ½ÕâÑùÎÊÌ⣬¾ÍÊÇÒªÇó¶¨ÆÚ½øÐÐÊý¾Ý¿âµÄ¼ì²é£¬Èç¹û·¢ÏÖÌØ¶¨Êý¾Ý£¬ÄÇô¾ÍÒª½øÐÐijÏî²Ù×÷£¬Õâ¸öÐèÇóÄØ£¬¿ÉÒÔÀûÓÃWindowsµÄ¼Æ»®ÈÎÎñ£¬¶¨ÆÚÖ´ÐÐijһ¸öÓ¦ÓóÌÐò£¬È¥¼ìË÷Êý¾Ý£»Ò²¿ÉÒÔÈóÌÐò×Ô¼º¿ØÖÆ¡£ÆäʵSQL Server×Ô¼ºÒ²¿ÉÒÔ´´½¨¼Æ»®ÈÎÎñ£¬¶¨ÆÚ½øÐÐÖ´ÐС£Èç¹ûÊý¾Ý¿â·þÎñÆ÷ÔÊÐí£¬¿ÉÒÔ¿¼ÂDzÉÓÃÕâÖÖ·½Ê½¡£
......