Uploading Data From Access To SQL Server
Uploading Data From Access To SQL Server
Import your data from Excel into Access. At this point, your table is ready for uploading directly into SQL
Server.
2. In the left-hand side of your screen, you should see the tables listed. Right-click on the table you
want to export. This will open a menu. Select the “Export” option from this menu, and the
“ODBC Database” option from the next sub-menu.
3. You will be prompted to give the table a name. As long as the table is named something OTHER
THAN a table that already exists in SQL Server, any name will work. I like to name my tables
Tmp[something]. That allows me to easily identify which are ones my temporary tables that I’ve
imported from Access as opposed to the real ones that I created using the Create Table
statements from the project instructions. I do not want to overwrite the tables I already created
from the Instructions. They contain the correct primary and foreign key constraints, which I do
not want to lose. Therefore, I want to copy the data from my Access imported tables into my
existing SQL Server tables. Notice in the screen below, my table is named TmpRegions.
4. After clicking OK for the table name, you will see a screen that allows you to select the Data
Source. Click the “Machine Data Source” tab.
The first time you upload a table to SQL Server, you will need to create a new data source. After
the first time, the data source you created will appear in the list of data sources on the Machine
Data Source tab. The following are instructions for creating a Machine Data Source the first
time. On the screen below, click the New button.
You may get the following warning. Don’t worry about it and just click OK.
5. The next screen should have “User Data source (Applies to this machine only)” already selected
for you. Just click the Next button.
6. Scroll down to the bottom of the listbox on the next screen and select SQL Server.
13. You should see a screen that looks like the one below. Click OK.
14. You should be back at the Test Data Source screen. Click OK on this screen.
15. The data source you just created should now appear in the Select Data Source dialog box. Select
it and click OK.
16. You should then see a confirmation screen saying that your table was successfully exported.
Click OK and check in SQL Server to make sure it exists.
One of the main reasons for performing this exercise is to expose you to new and effective ways of
importing, exporting, and manipulating data.
I like to use Access to massage my tables (both rows and columns) into the correct format. Then, I
upload them to SQL Server. Once they are in SQL Server, I simply execute the command to insert the
data from my tmp table into a real one using the following command:
INSERT Regions
SELECT * from tmpRegions
The key is that your columns in the tmp table have to match the columns in the real table. Before I
upload from access, I always add, delete, and rearrange the columns such that they match the real SQL
Server tables exactly. Thus, when I upload and dump the data, it easily pours itself into the real table
with the Update command.