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

¹¦ÄÜÇ¿´óµÄSQLÓï¾ä

1. ¸´ÖƱí½á¹¹
Sql´úÂë
   1. select * into B from A where 1=0;   
select * into B from A where 1=0;
 2.¸´ÖƱí¼Ç¼ ¸´ÖÆijЩ×Ö¶Î
Sql´úÂë
   1. insert into B(a, b, c) select d, e, f from A;   
insert into B(a, b, c) select d, e, f from A;
  ¸´ÖÆÕû¸ö±í¼Ç¼
Sql´úÂë
   1. insert into B select * from A;   
insert into B select * from A;
3.ÍâÁ¬½Ó²éѯ
Sql´úÂë
   1. select A.a, A.b, A.c, B.c, B.d, B.f from A LEFT OUT JOIN B ON A.a = B.c; ¡¡  
select A.a, A.b, A.c, B.c, B.d, B.f from A LEFT OUT JOIN B ON A.a = B.c; ¡¡
4.È¡Ìض¨Ê±¼äÄÚµÄÊý¾Ý
Sql´úÂë
   1. select * from A where datediff("minute", ¿ªÊ¼Ê±¼ä×Ö¶Î, getdate())>ʱ¼ä²î ¡¡  
select * from A where datediff("minute", ¿ªÊ¼Ê±¼ä×Ö¶Î, getdate())>ʱ¼ä²î ¡¡
5.Á½ÕŹØÁª±í£¬É¾³ýÖ÷±íÖÐÒѾ­ÔÚ¸±±íÖÐûÓеÄÐÅÏ¢
Sql´úÂë
   1. delete from A where not exists(select ID from B where A.infid=B.infid );  
delete from A where not exists(select ID from B where A.infid=B.infid );
6. ¸´ÔӵĶ༶Ìõ¼þ²éѯ
Sql´úÂë
   1. SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE   
   2.      from TABLE1,(SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE   
   3.                   from (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND   
   4.                         from TABLE2   
   5.                         WHERE TO_CHAR(UPD_DATE,’’YYYY/MM’’) =   
   6.         &nb


Ïà¹ØÎĵµ£º

¡¾»ã×Ü¡¿SQL CODE ¾­µä·¾«²Ê


¡¾»ã×Ü¡¿SQL CODE --- ¾­µä·¾«²Ê
Êý¾Ý²Ù×÷Àà SQLHelper.cs
ÎÞÏÞ¼¶·ÖÀà ´æ´¢¹ý³Ì
°ÙÍò¼¶·ÖÒ³´æ´¢
SQL¾­µä¶ÌС´úÂëÊÕ¼¯ 
ѧÉú±í ¿Î³Ì±í ³É¼¨±í ½Ìʦ±í 50¸ö³£ÓÃsqlÓï¾ä
SQL SERVER ÓëACCESS¡¢EXCELµÄÊý¾Ýת»»
 
Óαê
¸ù¾Ý²»Í¬µÄÌõ¼þ²éѯ²»Í¬µÄ±í
INNER JOIN Óï·¨
master.dbo.spt_val ......

Excelµ¼ÈëSQL£¨2£©

      ÓõÚÒ»ÖÖ·½·¨£¬ÉÏ´«·þÎñÆ÷ºó£¬ÔÚһЩ·þÎñÆ÷ÖУ¬¿ÉÄÜ»á³öÏÖÒÔÏ´íÎó£º
    ±ØÐëÔÚweb.configÖÐ¼Ó <system.web><identity impersonate="false"/></system.web> ,·ñÔò³öÏÖ´íÎó£ºSystem.Data.OleDb.OleDbException: δָ¶¨µÄ´íÎó¡£¼ÓÁËÒԺ󣬵ã¶à¼¸´ÎÁ´½Ó£¬» ......

¾«µäSQLÓï¾ä

·ÖÀàͳ¼Æ×ÜÊý²¢ÅÅÐò¶à±íÁªºÏ²éѯµÄÁ½ÖÖ·½·¨
Àý:
²éѯµØÇø±íÖи÷Ê¡ÏÂÃæ³ÇÊÐ×ÜÊý,²¢¶Ô²éѯ½á¹ûÈ¡Ç°Ê®Ãû
·¨Ò»:
select b.id,a.[name],b.counts from n_area a,(select top 10 parent_id as id,sum(parent_id) as counts from n_area where parent_id<>0 group by parent_id order by sum(parent_id) desc
) b where ......

sql Óï¾ä´¦Àí ÈÕÆÚ´¦Àí

DATENAME([Year],
      dbo.reservation.begintime) + N'Äê' + CAST(DATEPART([Month],
      dbo.reservation.begintime) AS varchar) + N'ÔÂ' + DATENAME([Day],
      dbo.reservation.begintime) + N'ÈÕ' + DATENAME([Hour], dbo.r ......

ms sql server ´´½¨Óû§


SQL code
´´½¨½ÇÉ«£¬Óû§£¬È¨ÏÞ
/*--ʾÀý˵Ã÷
ʾÀýÔÚÊý¾Ý¿âpubsÖд´½¨Ò»¸öÓµÓбíjobsµÄËùÓÐȨÏÞ¡¢ÓµÓбítitlesµÄSELECTȨÏ޵ĽÇÉ«r_test
Ëæºó´´½¨ÁËÒ»¸öµÇ¼l_test£¬È»ºóÔÚÊý¾Ý¿âpubsÖÐΪµÇ¼l_test´´½¨ÁËÓû§ÕË»§u_test
ͬʱ½«Óû§ÕË»§u_testÌí¼Óµ½½ÇÉ«r_testÖУ¬Ê¹Æäͨ¹ýȨÏ޼̳лñÈ¡ÁËÓë½ÇÉ«r_t ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ