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

¶¯Ì¬Ö´ÐÐSqlÓï¾äÓëÁÙʱ±íµÄÎÊÌâ(¶ÔÏóÃûÎÞЧ)

exec('selectIDENTITY(int,1,1)  as ID,fnum,into  #yuecu  from  store_store where  '+@Parameter)  
select  XX,XX1,XX2  from  #yuecu 
ÕâÑù´´½¨Ò»¸öÁÙʱ±íÒÔºóÎÒÔÙÏë´ÓÁÙʱ±íÖÐÈ¡Êý¾ÝÌáʾ¶ÔÏóÃû#yuecu ÎÞЧ£¬ÔΣ¬Èç¹ûÎÒ²»ÊÇʹÓÃexec()Ö´ÐÐsqlÓï¾äµÄ»°¾ÍûÓÐÈκÎÎÊÌâ,WHY?  
ÁÙʱ±íÓÐ×÷ÓÃÓòµÄ£¬ÉÏÃæµÄÁÙʱ±íÖ»ÔÚEXEC內²¿ÓÐЧ¡£
½â¾ö°ì·¨£º
¸ÄÓÃÈ«¾ÖÁÙʱ±í
exec('selectIDENTITY(int,1,1)  as ID,fnum,into  ##yuecu  from  store_store where  '+@Parameter)  
select * from  ##yuecu  


Ïà¹ØÎĵµ£º

oralce sqlÓÅ»¯34Ìõ

ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQL,ÒÔÏÂΪ±ÊÕßѧϰ¡¢ÕªÂ¼¡¢²¢»ã×ܲ¿·Ö×ÊÁÏÓë´ó¼Ò·ÖÏí£¡
£¨1£©      Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLE µÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom× ......

sql sever °²×°Ê±Ä³¸ö³ÌÐò¹ÒÆð½â¾ö·½°¸

SQL server°²×°Ê±Ê±£º“ÒÔǰµÄij¸ö³ÌÐò°²×°ÒÑÔÚ°²×°¼ÆËã»úÉÏ´´½¨¹ÒÆðµÄÎļþ²Ù×÷¡£ÔËÐа²×°³ÌÐò֮ǰ±ØÐëÖØÐÂÆô¶¯¼ÆËã»ú”´íÎó¡£
´ò¿ª×¢²á±í±à¼­Æ÷£¨¿ªÊ¼->ÔËÐÐ->regedit£©£¬ÔÚHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session ManagerÖÐÕÒµ½PendingFileRenameOperationsÏîÄ¿£¬²¢É¾³ýËü¡£ÕâÑù ......

SQLÓï¾äµ¼Èëµ¼³ö´óÈ«

/*******  µ¼³öµ½excel
exec master..xp_cmdshell ’bcp settledb.dbo.shanghu out c:\temp1.xls -c -q -s"gnetdata/gnetdata" -u"sa" -p""’
/***********  µ¼Èëexcel
select *
from opendatasource( ’microsoft.jet.oledb.4.0’,
  ’data source="c:\test.xls";user ......

SQL ÖÐhaving ºÍwhereµÄÇø±ð

group by
 
    ÔÚselect Óï¾äÖпÉÒÔʹÓÃgroup by ×Ӿ佫Ðл®·Ö³É½ÏСµÄ×飬Ȼºó£¬Ê¹ÓþÛ×麯Êý·µ»ØÃ¿Ò»¸ö×éµÄ»ã×ÜÐÅÏ¢£¬ÁíÍ⣬¿ÉÒÔʹÓÃhaving×Ó¾äÏÞÖÆ·µ»ØµÄ½á¹û¼¯¡£group by ×Ó¾ä¿ÉÒÔ½«²éѯ½á¹û·Ö×飬²¢·µ»ØÐеĻã×ÜÐÅÏ¢Oracle °´ÕÕgroup by  ......

sql serverµ¥±íµ¼Èë¡¢µ¼³ö£¨Í¨¹ýCSVÎļþ£©


µ¼³ö£º
Ö±½Ó´ò¿ª²éѯ·ÖÎöÆ÷²éѯҪµ¼³ö±íµÄÐÅÏ¢£¨select *  from ±í£©£¬µÃµ½µÄ½á¹ûȫѡ£¬ÓÒ¼üÁí´æÎª xxx.csvÎļþ  £¨µÃµ½¸Ã±íµÄËùÓÐÐÅÏ¢£¬CSVÎļþ¸ñʽ£©
µ¼È룺
Ê×ÏÈͨ¹ýsql server µÄÆóÒµ¹ÜÀíÆ÷Éú³ÉÒªµ¼³ö±íµÄ SQL½Å±¾£¬²½Ö裺Ҫµ¼³ö±í——ËùÓÐÈÎÎñ£¨ÓÒ¼ü£©——Éú³ÉSQL½Å±¾
µÃµ½¸Ã±íµÄ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ