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

SQL SERVERÈÕÆÚʱ¼äº¯Êý

 À´Ô´http://hi.baidu.com/smilevt/blog/item/04bddeef0fe3f42e2cf5348b.htmlÕâÀﻹÓкܶà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 ʱ0 ~ 23
Minute Mi n ·ÖÖÓ0 ~ 59
Second Ss s Ãë 0 ~ 59
Millisecond Ms - ºÁÃë 0 ~ 999
access ºÍ asp ÖÐÓÃdate()ºÍnow()È¡µÃϵͳÈÕÆÚʱ¼ä£»ÆäÖÐDateDiff,DateAdd,DatePartҲͬÊÇÄÜÓÃÓÚAccessºÍaspÖУ¬ÕâЩº¯ÊýµÄÓ÷¨Ò²ÀàËÆ
¾ÙÀý£º
1.GetDate() ÓÃÓÚsql server :select GetDate()
2.DateDiff('s','2005-07-20','2005-7-25 22:56:32')·µ»ØֵΪ 514592 Ãë
DateDiff('d','2005-07-20','2005-7-25 22:56:32')·µ»ØֵΪ 5


Ïà¹ØÎĵµ£º

SQLν´Ê

1¡¢Î½´Ê ν´ÊÔÊÐíÄú¹¹ÔìÌõ¼þ£¬ÒÔ±ãÖ»´¦ÀíÂú×ãÕâЩÌõ¼þµÄÄÇЩÐС£
2¡¢Ê¹Óà IN ν´Ê
ʹÓà IN ν´Ê½«Ò»¸öÖµÓëÆäËû¼¸¸öÖµ½øÐбȽϡ£ÀýÈ磺
SELECT NAME from STAFF WHERE DEPT IN (20, 15)
´ËʾÀýÏ൱ÓÚ£º
SELECT NAME from STAFF WHERE DEPT = 20 OR DEPT = 15
µ±×Ó²éѯ·µ»ØÒ»×éֵʱ£¬¿ÉʹÓà IN ºÍ NOT IN ÔËËã·û¡£ÀýÈç£ ......

shopxpÍøÉϹºÎïϵͳ v7.4´æÔÚSQL×¢È멶´

shopxpÍøÉϹºÎïϵͳ v7.4´æÔÚSql×¢È멶´¡£
ÎÊÌâÎļþ£ºxpCatalog_xpDesc.asp£¬xpCatalog_xpsmall_Desc.asp
ÎÊÌâ´úÂ룺
<%
dim shopxpbe_id, anclassname, shopxpse_id, nclassname
dim totalPut
dim CurrentPage, TotalPages
if request("shopxpbe_id")<>"" then
shopxpbe_id=request("shopxpbe_id")
e ......

SQL ±êÁ¿Öµº¯ÊýµÄµ÷ÓÃ

µ÷Óà MS SQL ±êÁ¿Öµº¯Êý£¬Ó¦¸ÃÔÚº¯ÊýÇ°Ãæ¼ÓÉÏ "dbo."£¬·ñÔò»á±¨ “²»ÊÇ¿ÉÒÔʶ±ðµÄ ÄÚÖú¯ÊýÃû³Æ”´íÎó¡£ÀýÈç
    DECLARE @WhichDB TINYINT;
    SELECT @WhichDB = user_GetWhichDB(1);--¿´¿´ÊÇÄĸöÊý¾Ý¿âµÄ
=================================================
-- ......

SQL Server2005ËĸöÅÅÐòº¯Êý¼ò½é

ÅÅÃûº¯ÊýÊÇSQL Server2005мӵŦÄÜ¡£ÔÚSQL Server2005ÖÐÓÐÈçÏÂËĸöÅÅÃûº¯Êý£º
1. row_number ×Ô¶¯Éú³ÉÐкÅ,ÐòºÅÓÉorder by ×ֶξö¶¨
2. rank over Filed, ÓÉrank overµÄ×ֶξö¶¨£¬Ãû´Î²»Á¬Ðø£¬ÈçÓÐ3¸ö²¢ÁеÚÒ»Ãû£¬ÔòºóÐøÃû´ÎÖ±½Ó´Ó4¿ªÊ¼
3. dense_rank£¬ºÍrankÏàËÆ£¬Ö»ÊÇÃû´ÎÁ¬Ðø£¬ÈçÓÐ3¸ö²¢ÁеÚÒ»Ãû£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ