Execute the SQL statement implementation by using SQLServer's query analyzer:
1. Import Access data into SQLServer
Perform the following statement in SQL Server to import data in the B04 table in the ACCESS to the SQLTableNaem table in SQL Server
INSERT INTO SQLTABLENAME (Sfield1, Sfield2, Sfield3, Sfield4, Sfield5, Sfield6)
SELECT
Convert (char (10
), Afield1)
, Afield2, Afield3, Afield4, Afield5, AFIELD6
From OpenDataSource ('microsoft.jet.oledb.4.0', 'data source = "c: /doc/accessdb.mdb"; Jet OLEDB: Database Password = ABC) ... B04
Description:
1.Convert (CHAR (10), AFIELD1) can convert the type of data, control the length; 2. In "OpenDataSource ('microsoft.jet.OleDb.4.0', 'data source =" C: / Doc / Accessdb. MDB "; Jet OLEDB: Database Password = ABC) ... B04" Data Source = "c: /doc/accessdb.mdb is the physical path for the Access database (guaranteed two databases on a machine); 3.Password = ABC "ABC" is the password of the Access database, if the database is not correct; 4.B04 is a table name in the Access database; 5. Can also add some conditions such as where afield = 'a' and ... Data, which is selected, INSERT INTO OpenDataSource ('Microsoft.jet.Oledb.4.0', 'data source = "C: / Data Source =" C: / Data Source = "C: / Data Source =" C: / Data Source = "C: / DOC / AccessDB .mdb "; Jet OLEDB: Database Password = ABC) ... B04 (Afield1, Afield2, Afield3, Afield4, Afield5, Afield6) Select sfield1, sfield2, sfield3, sfield4, sfield5, sfield6from sqltablename Description: 1. Can also add some Conditions such as WHERE AFIELD = 'A' and ..., there is a selection condition import data. Summary: This is inserted statements, only one form of INSERT in the article, and other forms can be used for data mutual guide.