sql serverÈÕÆÚʱ¼äº¯Êý
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
W
Ïà¹ØÎĵµ£º
°æȨÉùÃ÷£ºÔ´´×÷Æ·£¬ÈçÐèתÔØ£¬ÇëÓë×÷ÕßÁªÏµ¡£·ñÔò½«×·¾¿·¨ÂÉÔðÈΡ£
DB2ÁÙʱ±íÔÚSQL¹ý³ÌºÍSQLÓï¾äÖеIJâÊÔ×ܽá
²âÊÔÄ¿±ê£º
·Ö±ðÔÚSQL¹ý³ÌºÍSQLÓï¾äÖд´½¨ÁÙʱ±í£¬²¢²åÈëÊý¾Ý£¬¿´Ö´Ðнá¹ûÓÐʲôÒìͬ¡£
²âÊÔ»·¾³£º
DB2 UDB V9.1
Ö´Ðи½¼þÀïÃæµÄSQLÓï¾ä£¬µÃµ½Ò»¸ö±í¡ ......
1.¶Á³ö±íÖеÄ×Ö¶ÎÃû
ResultSet rs = test.selectSql("SELECT * from datainfo");
java.sql.ResultSetMetaData md=rs.getMetaData(); //¶Á³öÊý¾Ý¿âµÄ×Ö¶ÎÃû
int nColumn=md.getColumnCount(); //×Ö¶Î×ÜÊý
for(int i=0;i<nColumn;i++)
& ......
1 PLS_INTEGER
PLS_INTEGER¿ÉÒÔ´æ´¢Ò»¸öÓзûºÅµÄÕûÐÎÖµ£¬Æ侫¶È·¶Î§ºÍBINARY_INTEGERÒ»Ñù£¬ÊÇ£º-2^31~2^31¡£
PLS_INTEGERºÍNUMBER±È½ÏÆðÀ´£¬ÆäÓŵãÊÇ£º
1).Õ¼ÓнÏÉٵĴ洢¿Õ¼ä£»
2).¿ÉÒÔÖ±½Ó½øÐÐËãÊõÔËË㣨ÔÚNUMBERÉϲ»ÄÜÖ±½Ó½øÐÐËãÊõÔËË㣬Èç¹ûÒª¼ÆË㣬NUMBER±ØÐëÏȱ»×ª»»³É¶þ½øÖÆ£©¡£ËùÒÔÔÚ½øÐÐËãÊõµÄʱºòPLS_INTEGER ......
µ÷Óà MS SQL ±êÁ¿Öµº¯Êý£¬Ó¦¸ÃÔÚº¯ÊýÇ°Ãæ¼ÓÉÏ "dbo."£¬·ñÔò»á±¨ “²»ÊÇ¿ÉÒÔʶ±ðµÄ ÄÚÖú¯ÊýÃû³Æ”´íÎó¡£ÀýÈç
DECLARE @WhichDB TINYINT;
SELECT @WhichDB = user_GetWhichDB(1);--¿´¿´ÊÇÄĸöÊý¾Ý¿âµÄ
=================================================
-- ......
ÅÅÃûº¯ÊýÊÇSQL Server2005мӵŦÄÜ¡£ÔÚSQL Server2005ÖÐÓÐÈçÏÂËĸöÅÅÃûº¯Êý£º
1. row_number ×Ô¶¯Éú³ÉÐкÅ,ÐòºÅÓÉorder by ×ֶξö¶¨
2. rank over Filed, ÓÉrank overµÄ×ֶξö¶¨£¬Ãû´Î²»Á¬Ðø£¬ÈçÓÐ3¸ö²¢ÁеÚÒ»Ãû£¬ÔòºóÐøÃû´ÎÖ±½Ó´Ó4¿ªÊ¼
3. dense_rank£¬ºÍrankÏàËÆ£¬Ö»ÊÇÃû´ÎÁ¬Ðø£¬ÈçÓÐ3¸ö²¢ÁеÚÒ»Ãû£ ......