excelµ¼Èësql server2005µÄÎÊÌâ
[Excel Ô´ [1]] ´íÎó: Êä³ö¡°Excel Ô´Êä³ö¡±(9) É쵀 Êä³öÁС°Description 3¡±(546) ³ö´í¡£·µ»ØµÄÁÐ״̬ÊÇ:¡°Îı¾±»½Ø¶Ï£¬»òÕßÒ»¸ö»ò¶à¸ö×Ö·ûÔÚÄ¿±ê´úÂëÒ³ÖÐûÓÐÆ¥ÅäÏî¡£¡±¡£
¸ÃÁÐÔÚexcelÖÐ×Ϊ308¸ö×Ö·û£¬µ«ÊÇexcelÔ´ÖеÄÍⲿÁкÍÊä³öÁÐ×î¶àÖ»ÄÜÉèΪNvarchar(255),Èç¹ûÉ趨³¤¶È³¬¹ý255£¬Ôò³öÏÖ¾¯¸æ£¬Ô´ÁÐÊôÐÔ²»Æ¥Å䣬ִÐÐҲͨ²»¹ý¡£Ê¹ÓÃNtextÀàÐÍÒ²³¢ÊÔ¹ý£¬²»Æ¥Åä¡£
ÎÒʹÓÃado.netµ¹ÊǰÑËüµ¹Èëµ½Êý¾Ý¿âÁË£¬µ«ÊÇ·¢ÏÖËùÓг¬¹ý255µÄ¶¼±»½Ø¶ÏÁË¡£
ÎÒÊÔ¹ý°ÑexcelÖиÃÁÐÉèΪÎı¾¸ñʽҲ²»ÐС£
ÕâÖÖ³¤×Ö·ûÁÐÓ¦¸ÃÔõô´¦Àí£¿
ÎÒÏÖÔÚµ¼EXCEL¶¼ÊÇÖ±½ÓÔÚEXCELÖÐÆ´³öINSERTÓï¾ä£¬·½±ãÓÖÁé»î
ÔÚEXCELÖÐÆ´³öINSERTÓï¾ä£¿ÈçºÎ×ö£¬ÇëÖ¸µ¼£¬Ð»Ð»¡£
ÓÃOpenDataSourceÂð£¿
ûÑо¿¹ý
ûÑо¿¹ý
SQL code:
--»òÕß¿½貝µ½Îı¾ÖÐbulk insert
bulk insert test
from 'E:\Test.txt'
with(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
select * from test
ÎÒ²»Ï²»¶ÓÃÓï¾ä ÎÒÒ»°ã¶¼Ï°¹ßÓõ¼Èëµ¼³ö¹¤¾ß
×î½ü±»¿Í»§Ò»Ð©ÂÒÆß°ËÔãµÄexcel¸ãµÄ½¹Í·Àö¸ñʽÎޱȻìÂÒ£¬ÓïÑÔÒ²¸úÎÒÃDz»Í¬¡£¡£
Ïà¹ØÎÊ´ð£º
Ö´ÐеÄ˳Ðò£º
1£©Îļþä¯ÀÀ¿ò£¨Ñ¡ÔñÎļþʹÓã©
Ñ¡ÔñºÃÎļþºó
µã»÷Ò»¸öµ¼Èë°´Å¥µÄʱºò £¬°ÑÉÏÃæÉÏ´«¿òÀïµÄcsvÎļþÒÔÒ»¸öIDΪÎļþÃû£¬ÉÏ´«µ½**/**Îļþ¼ÐÏÂ
2£©¶ÁÈ¡Õâ¸öÎļþ¼ÐϵÄcsvµÄÎļþ£¬×ª»»³Ésql
3 ......
´ó¼Ò°ïæ¿´¿´Õâ2¸ösqlÓï¾äÄĸö²éѯµÄËٶȸü¿ìµã¡£Ð»Ð»°ïæ¡£±È½Ï׿±¡£ÔÚ×öÐÔÄܲâÊÔ¡£
select * from
±íA LEFT OUTER JOIN ±íB ON (±íA.id || ' ' =±íB.id) ,±íC , ±íD, ±íE
WhereÆäËûÌõ¼þ
select * ......
ÒÑÖª´ÓB,±íÖÐÕÒ³öID, NAMEÁ½ÏîÓëC±íÏàͬµÄÊý¾Ý£¬ÔÙÒÀ¾ÝB±íÖо¹ý²éѯ³öÀ´µÄID,CODEÁ½ÏîÊý¾Ý²éѯÓëA±íID,CODEÁ½ÏîÏàͬµÄÊý¾ÝÖжÔÓ¦µÄEMAILÀ´£¬²¢ÁгöÈçÏÂD±íµÄÐÎʽ£¬²»ÖªÎÒÊÇ·ñ±íʾÇå³þ£¿Âé·³°ïÎÒÁÐһϹ«Ê½ºÃÂð£¿Íò· ......
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......
±íÈçÏÂ
½ÌÊÒID ×ùλÊý ¿ªÊ¼Ê±¼ä ½áÊøÊ±¼ä 2009Äê1ÔÂ1ÈÕ 2009Äê1ÔÂ2ÈÕ 2009Äê1ÔÂ3ÈÕ
101 50 08£º00 08£º30 30 40 50
101 50 09£º00 ......