SQL¶ÁÈ¡EXCEL
Ö±½ÓÔÚSQL²éѯ·ÖÎöÆ÷ÖжÁÈ¡EXCELÎļþÐèҪʹÓõ½OPENDATASOURCE¡£
µ«ÊÇʹÓÃËü֮ǰÐèÒª½øÐÐÅäÖÃһϡ£¼ÇµÃÈçÏÂÅäÖÃÊDZØÐëµÄ£º
1¡¢Ö´ÐÐÕâÁ½¸ö´æ´¢¹ý³Ì£º
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
ËüµÄ×÷Óãº
µÚÒ»¸öÊÇ£ºÊÇ·ñÖ§³Ö¸ß¼¶Ñ¡ÏîµÄ£¬1Ϊ֧³Ö0Ϊ²»Ö§³Ö¡£
µÚ¶þ¸öÊÇ£ºÊÇ·ñÖ§³Ö·Ö²¼Ê½²éѯ£¬
1Ϊ֧³Ö0Ϊ²»Ö§³Ö¡£
¶øÇÒÒ»¶¨ÊÇÏÈÖ§³Ö¸ß¼¶Ñ¡ÏÔÙ¿ÉÒÔÉèÖ÷ֲ¼Ê½²éѯ£¬ÒòΪ·Ö²¼Ê½²éѯ±¾Éí¾ÍÊÇ
Ò»¸ö¸ß¼¶Ñ¡ÏîÀ´µÄ¡£
2¡¢Ê¹ÓÃOPENDATASOURCE£¬ËüÓÐÁ½ÖÖÓï·¨
£¨1£©SELECT * from OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=D:\TempExcelData\Exl_Test_01.xls;Extended Properties=EXCEL 5.0')...[Student$]
£¨2£©select *
from Openrowset('Microsoft.Jet.OLEDB.4.0','EXCEL 8.0;HDR=YES;User id=admin;Password=;IMEX=1;
DATABASE=D:\TempExcelData\Exl_Test_01.xls', Student$)
3¡¢ÓÃÍêºóÒª¹Ø±ÕµÚÒ»²½´ò¿ªµÄ¶«Î÷
exec sp_configure 'show advanced options',0
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
°´Õմ˲½²»Ò»¶¨¿ÉÒÔ²éѯµ½ÄãEXCELµÄÊý¾Ý£¬¿ÉÄÜ»¹»áÓÐÆäËüµÄ´íÎ󣬱ÈÈç˵ȨÏÞ
²»×ã¹»Òý·¢ÆäËüµÄÎÊÌâ°¡£¬ÒªÔÚÍøÉÏÕÒ¶àһϣ¬¾ÍÈçÎÒÅäÖõÄʱºò£¬ÓõÄÊÇSA½øÈ¥µÄ£¬
µ«ÊÇSA²»ÊÇSYSADMINISTRATORÕâÒ»×飬Ҫ¼Ó½øÈ¥ºó²ÅÓÐȨÏÞ£¬²ÅÄÜ˳Àû²éµ½Êý¾Ý
Ïà¹ØÎĵµ£º
SQLÓï¾äÓÅ»¯¼¼Êõ·ÖÎö
²Ù×÷·ûÓÅ»¯
IN ²Ù×÷·û
ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ×¶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£
µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊDZȽϵ͵쬴ÓORACLEÖ´ÐеIJ½ÖèÀ´·ÖÎöÓÃINµÄSQLÓë²»ÓÃINµÄSQLÓÐÒÔÏÂÇø±ð£º
¡¡¡¡¡¡ORACLEÊÔͼ½«Æäת»»³É¶à¸ö±íµÄÁ¬½Ó£¬Èç¹ûת»»²»³É¹¦ÔòÏÈÖ´ÐÐINÀïÃæµÄ×Ó²éѯ£¬ ......
Èç¹ûÏë²éÕÒ“_cs”½áβµÄµÄÕË»§
select * from [user] where loginname like '%_cs'ÊDz»Ðеģ¬_ ±»ÈÏΪÊÇÈÎÒâµÄ×Ö·û£¬
ËùÒÔÐèҪתÒå×Ö·û£¬ÓÐÁ½ÖÖд·¨£º
select * from [user] where loginname like '%[_]cs'
select * from [user] where loginname like '%/_cs' escape'/'
ͨÅä·ûº¬Òå
%
°üº¬Áã¸ö»ò¸ü¶à×Ö· ......
µ÷ÊÔSQLÊý¾Ý£¬·¢ÏÖÊý¾Ý¼Ç¼¼¯Öظ´ÎÊÌ⣬ËùÒÔ£¬¼ÆËã³öµÄÊý¾Ý½á¹û±¶ÊýÎÊÌ⡣ͨ¹ýµ÷ÊÔSQL£¬·¢ÏÖÊÇÎïÁϵķÖÀà²úÉúÖØ¸´£»Ö®ËùÒÔ²úÉúÖØ¸´£¬ÎïÁϵķÖÀà±ê×¼²»Ò»Ñù£¬Óëʵ¼ÊµÄÒµÎñÓйء£³ÌÐòÖÐÒ»Ö±ÓÃÀà±ðÀ´Çø·ÖÀà±ð£¬¶øÕâÕÅ´Îʵ¼ÊÒµÎñ²»ÐèÒªÓëÀà±ðÓйأ¬ËùÒÔ£¬Ã»ÓжÔÓ¦µÄ¹ýÂËÌõ¼þ£¬ËùÓеÄÀà±ðÈ«²¿Ñ¡³öÀ´ÁË¡£È»ºó£¬°ÑÏÂÃæµÄºìÉ«×Ö¶Î×¢ ......
ÏÂͼÏÔʾÁËÊý¾Ý¿â±¸·ÝʱÎļþ¶ÁдµÄ¹ý³Ì£º
ÔÚ±¸·ÝÆÚ¼ä£¬SQL Server»áÔÚÊý¾Ý¿âÎļþÕâ±ßΪÿһÅÌ·û(Volume)´´½¨Ò»¸ö¶ÁÏ̡߳£¶ÁÏ̵߳Ť×÷ºÜ¼òµ¥£¬¾ÍÊÇ´ÓÎļþÖеÄÊý¾ÝÄÚÈÝ¡£Ã¿´ÎÕâ¸öÏ̶߳¼»á´ÓÎļþÖжÁ³ö²¿·ÖÊý¾Ý£¬È»ºó°ÑÊý¾Ý´æµ½»º³åÖÐ(buffer)¡£ÒòΪÓжà¸ö»º³å¿ÉÓã¬ËùÒÔÖ»ÒªÓлº³å¿ÉÒÔдÈëÊý¾Ý£¬¶ÁÏ߳̿ÉÒÔ²»Í£µÄ¶ÁÊý¾Ý¡ ......
sql Á½±í¹ØÁª ¸üÐÂ
update set from Óï¾ä¸ñʽ
SybaseºÍSQL SERVER£ºUPDATE...SET...from...WHERE...µÄÓï·¨£¬Êµ¼ÊÉÏ´ÓÔ´±í»ñÈ¡¸üÐÂÊý¾Ý¡£
ÔÚ SQL ÖУº
Update A SET A.dept =B.name
from A LEFT JOIN B ON B.ID=A.dept_ID ......