Sunday, January 16, 2011

Import excel & text to Access



select *
into
[excel 8.0;hdr=yes; database=C:\Documents and Settings\090302\My Documents\DATA\DA05\stest.xls;].[sheet1]
from
[excel 8.0;imex=1;hdr=yes;database=C:\Documents and Settings\090302\My Documents\DATA\DA05\s265001m.xls;].[sheet1$]
where instr('123456789',left(序號,1))<>0
and 廠商名稱<>''

select data from excel sheet (sheet1) and output to a new excel file(stest.xls) sheet1, be sure to notice the dollar sign in source file. In this example, first to arrange source file's column title to fit data contents and use access sql query to sort what you want.

select * from [Excel 8.0;HDR=Yes; IMEX=1; Database=C:\Documents and Settings\earl\My Documents\存出保證金194001.xls].[VES資料$]
select data from excel sheet(ves資料), make sure that the fields in access and excel are identical.
select * from [text;HDR=No; IMEX=1; Database=d:\ftp\data\].[ves533.txt]
select data from text file named ves533.txt, be sure to check you have schema.ini in the same data folder.

insert into ves100 select * from [Excel 8.0;HDR=Yes; IMEX=1; Database=C:\Documents and Settings\earl\My Documents\存出保證金194001.xls].[VES資料$]import data to access from excel.

SELECT * FROM [d:/ftp/data/audit2.mdb].[trans] where 傳票日期 alike '10001%' order by 傳票日期, 傳票編號
select data from other access database, you may insert data from other database.

SELECT * FROM [d:/ftp/data/audit2.mdb].ves8903_9908 WHERE 會計科目='247031' ORDER BY 傳票日期, 傳票編號
select data from other access database, you don't need to quote the table you use to retreave data.