---------- DBF import SQL Server table ----------
The following uses SQL2000, VFP6, and above as an example.
Method 1: execute the following statement in the query analyzer (select the corresponding database first)
-- If the SQL table that accepts the imported data already exists
Select * from openrowset ('msdasql ', 'driver = Microsoft Visual FoxPro Driver; SourceType = DBF; SourceDB = c :\', 'select * from aa. dbf ')
-- You can also import the corresponding column name, for example:
Insert into an existing SQL table name (column name 1, column name 2 ...) select (corresponding to column 1, corresponding to column 2 ...) from openrowset ('msdasql ', 'driver = Microsoft Visual FoxPro Driver; SourceType = DBF; SourceDB = c: \', 'select * from aa. dbf ')
-- If the SQL table that accepts the imported data does not exist, create
-- Method 1:
Select * Into the SQL table name to be generated from OpenRowSet ('Microsoft. jet. oledb.4.0 ', 'dbase IV; HDR = no; IMEX = 2; database = c: \', 'select * From DBF table name. dbf ')
-- Method 2:
Select * Into the SQL table name to be generated from OpenRowSet ('Microsoft. jet. oledb.4.0 ', 'dbase III; HDR = no; IMEX = 2; database = c: \', 'select * From DBF table name. dbf ')
-- Method 3:
Select * Into the SQL table name to be generated from OpenRowSet ('msdasql ', 'driver = Microsoft Visual FoxPro driver; sourcetype = DBF; sourcedb = c :\', 'select * From DBF table name. dbf ')
-- After the SQL Server is imported using the first two methods, if the source table is opened with VFP, the system does not prompt "file cannot be accessed". After the statement is executed, the source table is disabled. However, it is not satisfactory that the SQL table fields in the source table are converted to nvarchar after being imported using the first two methods.
-- The third method has one drawback: After importing the DBF table into SQL Server, you can use VISUAL FOXPRO to open the DBF table immediately and the system will prompt "file access unavailable ", that is, the table is still opened by SQL. However, after about one minute, you can open the DBF table, indicating that the analyzer will shut down the table after a period of time.
-- You can export only a few fields.
Select * into the SQL table name to be generated from openrowset ('msdasql ', 'driver = Microsoft Visual FoxPro Driver; SourceType = DBF; SourceDB = c: \', 'select Field 1, field 2 from aa. dbf ')
/* -- Description:
SourceDB = c: \ is the directory where dbf Files are stored.
Aa. DBF is the name of the dbf file.