In this answer i will provide 2 approaches to achieve this:
- using SSIS
- using C#
(1) SSIS approach
You must get the Access tables list into a variable of type System.Object, then loop over the tables names using a Foreach Loop container. There are many links that gives detailed informations, as example you can refer to the following SO answer it can gives you some insights:
(2) C# approach
Recently i started a new project on Git-Hub, which is a class library developed using C#. You can use it to import tabular data from excel, word , powerpoint, text, csv, html, json and xml into SQL server table having a different schema definition using schema mapping approach. check it out at:
You can use a similar code:
string con = @"Data Source=.\SQLInstance;Initial Catalog=tempdb;integrated security=SSPI;";
using (SchemaMapperDLL.Classes.Converters.MsAccessImport smAccess = new SchemaMapperDLL.Classes.Converters.MsAccessImport(@"U:\Passwords.mdb"))
{
using (SchemaMapperDLL.Classes.SchemaMapping.SchemaMapper SM = new SchemaMapperDLL.Classes.SchemaMapping.SchemaMapper("dbo","passwords"))
{
SM.CreateDestinationTable(con);
//Read Access
smAccess.BuildConnectionString();
smAccess.getSchemaTable();
foreach (DataRow schRow in smAccess.SchemaTable.Rows)
{
string strTablename = schRow["TABLE_NAME"].ToString().Trim('\'');
DataTable dt = smAccess.GetTableByName(strTablename);
bool result = SM.ChangeTableStructure(ref dt);
if (result == true)
{
SM.InsertToSQLUsingSQLBulk(dt, con);
}
}
}
}