delphiµ¼Èëexcelµ½sqlserverµÄsqlÓï¾äÎÊÌâ
'Select * into '+TempTableName+' from OpenDataSource(''Microsoft.JET.OLEDB.4.0'',''Data Source=' +ExcelFilePath+';Mode=Read;Extended Properties=Excel 5.0;Persist Security Info=True'')...[' +SheetName+'$]'; Èç¹ûÎÒµÄexcel±íÖеÄsheetname´øÓС°£¨£©¡±£¨±ÈÈçsheetnameÊÇ£º¼Û¸ñ£¨Ïêϸ£©£©Õâ¸öµÄ»°£¬Õâ¾äÓï¾ä¾Í»á±¨´í¡£ ÔÚÎÒ²»ÐÞ¸ÄsheetnameµÄÇ°ÌáÏ£¬ÎÒÔõôÈÃÕâ¸ösqlÓï¾ä²»±¨´í£¬ÄÜÕýÈ·Ö´ÐÐÄØ£¿
'SELECT * into '+TempTableName+' from openrowset(''MICROSOFT.JET.OLEDB.4.0'', ''Excel 5.0;HDR=YES;DATABASE='+ExcelFilePath+''',''select * from ['+SheetName+'$]'')'; ѧϰÒýÓà 'Select * into '+TempTableName+' from OpenDataSource(''Microsoft.JET.OLEDB.4.0'',''Data Source=' +ExcelFilePath+';Mode=Read;Extended Properties=Excel 5.0;Persist Security Info=True'')...[' +SheetName+'$]'; Èç¹ûÎÒµÄexcel±íÖеÄsheetname´øÓС°£¨£©¡±£¨±ÈÈçsheetnameÊÇ£º¼Û¸ñ£¨Ïêϸ£©£©Õâ¸öµÄ»°£¬Õâ¾äÓï¾ä¾Í»á±¨´í¡£ ÔÚÎÒ²»ÐÞ¸ÄsheetnameµÄÇ°ÌáÏ£¬ÎÒÔõôÈÃÕâ¸ösqlÓï¾ä²»±¨´í£¬ÄÜÕýÈ·Ö´ÐÐÄØ£¿ ´ó¸ç£¬ÎÒµÄÎÊÌâ²»ÊDz»»áµ¼È룬Êǵ¼ÈëµÄʱºòsheetnameÈç¹ûÓС°()¡±Õâ¸ö×Ö·ûµÄ»°¾Íµ¼Èëʧ°Ü¡£
Ïà¹ØÎÊ´ð£º
´ó¼Ò°ïæ¿´¿´Õâ2¸ösqlÓï¾äÄĸö²éѯµÄËٶȸü¿ìµã¡£Ð»Ð»°ïæ¡£±È½Ï׿±¡£ÔÚ×öÐÔÄܲâÊÔ¡£ select * from ±íA LEFT OUTER JOIN ±íB ON (±íA.id || ' ' =±íB.id) ,±íC , ±íD, ±íE WhereÆäËûÌõ¼þ select * ......
sql¿ÉÒÔÓÐÁ½¸öÒÔÉϵĴ¥·¢Æ÷Â𣿣¿ÎÒÖ¸µÄÊÇfor´¥·¢Æ÷£¬ÄÇÆäËûµÄÄØ£¿£¿ ʲôÒâ˼£¿ ¿ÉÒ﵀ 10¸ö¶¼Ã»ÎÊÌâ ¿ÉÊÇÎÒдÁËÁ½¸öfor insert ´¥·¢Æ÷£¬Ôì³É½ø³Ì×èÈûÁËÄØ£¿Ôõô°ìÄØ£¿Çë¸ßÈËÖ¸µã ......
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ ÀýÈç£ ......
ÊÇÕâÑùµÄ£¬ÎÒÓÃÊÇODBCÊý¾ÝÔ´Á¬½Ó·þÎñÆ÷µÄÊý¾Ý¿â£¬ÏÖÔÚÎÒ¾õµÃºÜÂé·³£¬ÒòΪҪΪÿÈç»úÌí¼Ó¶ÔÓ¦µÄÊý¾ÝÔ´£¬Ïë°ÑËû¸Ä³ÉADO·½·¨À´·ÃÎÊ·þÎñÆ÷µÄÊý¾Ý¿âÄÜʵÏÖÂð£¿ÒªÔõôд¡£ ±ÈÈç·þÎñÆ÷ÀïÓжþ¸öÊý¾Ý¿âdata1 ºÍdata2£¬¿Í»§ ......