Quantcast
Channel: ASP Free » Linked Table Manager
Viewing all articles
Browse latest Browse all 2

Link SQL Server Data to an Access Database

$
0
0
Linking SQL Server data to an Access database is an alternative to simply importing the data. You may want to link to SQL Server data if your database has many large tables that are difficult to import. Maybe you want to run queries and generate reports on your SQL Server data, but don’t want to go through the trouble of copying it. Or maybe you just want to continue storing data in SQL Server but have it available to work with in Access at the same time. Whatever the case may be, it’s a process that is worth learning.

The process of linking as it is described in this tutorial allows you to link a table or view in a SQL Server database to Access.  Doing so results in Access creating a new “linked” table that mimics the source object’s (in this case the SQL Server database) structure and contents.  Linking is beneficial because it essentially kills two birds with one stone.  Once your two entities are linked, the changing of data in the SQL Server database or in Access via the Datasheet view or Form view gets reflected on both sides of the equation.

How to Get Your Data Ready before Linking

Before you begin the necessary preparation for the linking process, you will need to have the proper information in place to connect to your SQL Server database.  If you are not the database administrator in charge, contact them to secure the relevant database login information first.

Once the necessary login information is in your hands, connect to the SQL Server database containing the data you want to link to Access. 

You will have the option to link to multiple objects when executing a single linking operation.  This helps to save time, but it could also bring problems if your source data is not in a linking-friendly format.  As mentioned earlier, you can link to a table or view in a SQL Server database.  Locate the tables or views that you intend to link to.  To avoid any issues during the linking operation, check over your SQL Server source data and keep these points in mind:

1. Your data must be limited to a maximum of 255 fields in a table, as that is all that Access will support.  In other words, if you happen to try to link to more than 255 fields, only the first 255 will actually be included in the linked table.

2. If you have read-only columns in your SQL Server object, they will maintain their read-only status in Access.

3. You will not be able to add, delete, or change any of your fields in a linked table when you are working in Access. 

4. If you plan on performing actions such as removing a column, changing a column, etc., it will have to be done either from the SQL Server database itself or via an Access project connected to the database.

Now that your SQL Server data is inspected and ready to go, you have to decide whether you want to link it to an existing Access database or a new, blank one.  To link to a blank Access database, click on File, click on New, and click on Blank Database. 

If you don’t want to use a blank database, locate the existing Access database where you want your linked tables to appear.  Obviously, you will need to have permission to add data to the database, or the linking will not work.  As an aside, when you link Access to a SQL Server object, the new linked table in Access will carry the same name as its SQL Server source object.  Any duplication of names will be prevented by adding numbers to the end of the names such as Table1, Table2, etc.

How to Link Your Data

So, you have your SQL Server source data and your destination Access database identified.  Now, it’s time to actually link them. 

Open your destination database and look for the External Data tab.  Go to the Import & Link group and select ODBC Database.  Click on the Link to the data source by creating a linked table option.  Click OK. 

In the Select Data Source window, find and select the .dsn file you want to use for the operation, and click OK.  If this describes your situation, skip the next two bulleted sections and move to the next.

• If you prefer to create a new data source name (DSN), click New.  This will start the Create New Data Source Wizard.  From the driver list, select SQL Server, and click Next.  Enter a name for the .dsn file, and click Next.  Double-check your information, and click Finish. 

• The Create a New Data Source to SQL Server wizard will appear.  You can type a description of the data source in the Description field, or skip it.  Enter the name of the SQL Server you want to connect to in the Which SQL Server do you want to connect to field, and click Next.  Decide whether to use Windows NT authentication or SQL Server authentication, and click Next.  Select the check box next to Change the default database to if you want to connect to a specific database.  Select the database and click Next.  Click Finish, and click Test Data Source.  If the test completes successfully, click OK to close out the wizard.  Otherwise, change your settings until the test completes without any issues so you can finish the wizard.

You should now see the Link Tables window in Access.  Select the tables or views you want to link to under the Tables section, and click OK.  Linking will occur.  Once complete, you will see the new linked tables in Access’ Navigation pane. 

If you want to update a linked table in Access to reflect your SQL Server object’s latest structure, you can do so easily by first right-clicking the table in the Navigation Pane and selecting the Linked Table Manager option.  You can either select individual linked tables to update or Select All for a comprehensive update.  Click OK to complete the update. 


Viewing all articles
Browse latest Browse all 2

Trending Articles