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

SQLʱ¼äº¯Êý

 
SQLʱ¼äº¯Êý
--ÈÕÆÚת»»²ÎÊý,ÖµµÃÊÕ²Ø
select CONVERT(varchar, getdate(), 120 )2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')20040912110608
select CONVERT(varchar(12) , getdate(), 111 )2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )20040912
select CONVERT(varchar(12) , getdate(), 102 )2004.09.12
ÆäËüÎÒ²»³£ÓõÄÈÕÆÚ¸ñʽת»»·½·¨:
select CONVERT(varchar(12) , getdate(), 101 )09/12/2004
select CONVERT(varchar(12) , getdate(), 103 )12/09/2004
select CONVERT(varchar(12) , getdate(), 104 )12.09.2004
select CONVERT(varchar(12) , getdate(), 105 )12-09-2004
select CONVERT(varchar(12) , getdate(), 106 )12 09 2004
select CONVERT(varchar(12) , getdate(), 107 )09 12, 2004
select CONVERT(varchar(12) , getdate(), 108 )11:06:08
select CONVERT(varchar(12) , getdate(), 109 )09 12 2004 1
select CONVERT(varchar(12) , getdate(), 110 )09-12-2004
select CONVERT(varchar(12) , getdate(), 113 )12 09 2004 1
select CONVERT(varchar(12) , getdate(), 114 )11:06:08.177
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 Ö¸¶¨µÄ·½Ê½£¬·µ»Ødate


Ïà¹ØÎĵµ£º

dzÎöSQL ServerÈý´óËã·¨µÄI/O³É±¾

 
1. Nested Loop Join(ǶÌ×Ñ­»·Áª½á)
Ëã·¨£º
Æä˼·Ï൱µÄ¼òµ¥ºÍÖ±½Ó£º¶ÔÓÚ¹ØϵRµÄÿ¸öÔª×é r ½«ÆäÓë¹ØϵSµÄÿ¸öÔª×é s ÔÚJOINÌõ¼þµÄ×Ö¶ÎÉÏÖ±½Ó±È½Ï²¢É¸Ñ¡³ö·ûºÏÌõ¼þµÄÔª×顣д³Éα´úÂë¾ÍÊÇ£º
´ú¼Û£º
±»Áª½áµÄ±íËù´¦ÄÚ²ã»òÍâ²ãµÄ˳Ðò¶Ô´ÅÅÌI/O¿ªÏúÓÐ×ŷdz£ÖØÒªµÄÓ°Ïì¡£¶øCPU¿ªÏúÏà¶ÔÀ´ËµÓ°Ïì½ÏС£¬Ö÷ÒªÊÇÔª×é¶ÁÈ ......

SQL Server¿ª·¢¹ý³ÌÖеÄÊ®ÖÖ³£¼ûÎÊÌâ×ܽá(2)

SQL Server 2005ÖеĴ洢¹ý³Ì²¢·¢ÎÊÌâ
ÎÒÔÚSQL Server2005ÖÐÓöµ½Á˲¢·¢ÎÊÌâ¡£ÎÒ³ÖÓгµÆ±µÄ¹«¹²Æû³µÉÏÓÐһЩ¿ÕÏеÄ×ùλ¡£ÎÒÔÚ²åÈëÏúÊ۵IJéƱ֮ǰ£¬ÐèÒª²é¿´ÊÇ·ñ»¹ÓпÕÏеÄ×ùλ¡£ÎҵĴ洢¹ý³Ì×öµÄÊÂÇéÈçÏÂËùʾ£º
create PROCEDURE add_ticket — parameters DECLARE free_seats int BEGIN TRANSACTION select free_se ......

ÓÃÒ»¾äSQLÈ¡³öµÚ m Ìõµ½µÚ n Ìõ¼Ç¼µÄ·½·¨

 1 --´ÓTable ±íÖÐÈ¡³öµÚ m Ìõµ½µÚ n ÌõµÄ¼Ç¼£º(Not In °æ±¾)
 2
 3 SELECT TOP n-m+1 *
 4 from Table
 5 WHERE (id NOT IN (SELECT TOP m-1 id from Table )) 
 6
 7
 8 --´ÓTABLE±íÖÐÈ¡³öµÚmµ½nÌõ¼Ç¼ (Exists°æ±¾)
 9
10 SELECT TOP n-m+1 * from ......

SQL ServerÊý¾Ý¿â±¸·ÝºÍ»Ö¸´´ëÊ©

 ¡¡Ò»¡¢±¸·ÝÊý¾Ý¿â
¡¡¡¡1¡¢´ò¿ªSQLÆóÒµ¹ÜÀíÆ÷£¬ÔÚ¿ØÖÆ̨¸ùĿ¼ÖÐÒÀ´Îµã¿ªMicrosoft SQL Server
¡¡¡¡2¡¢SQL Server×é-->Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷-->Ë«»÷´ò¿ªÊý¾Ý¿âĿ¼
¡¡¡¡3¡¢Ñ¡ÔñÄãµÄÊý¾Ý¿âÃû³Æ£¨ÈçÂÛ̳Êý¾Ý¿âForum£©-->È»ºóµãÉÏÃæ²Ëµ¥ÖеŤ¾ß-->Ñ¡Ôñ±¸·ÝÊý¾Ý¿â
¡¡¡¡4¡¢±¸·ÝÑ¡ÏîÑ¡ÔñÍêÈ«±¸·Ý£¬Ä¿µÄÖеı ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ