odbc reports how to use access to work with ms sql server database

53
ODBC REPORTS How to Use Access to work with MS SQL Server Database

Upload: harold-bruce

Post on 27-Dec-2015

231 views

Category:

Documents


1 download

TRANSCRIPT

ODBC REPORTSHow to Use Access to work with MS SQL Server Database

Open This folder

Open Access

Open a blank database

Give the DB an appropriate

name.

Open the External Data menu

Click on the ODBC Database

ODBC stands for Open Database ConnectivityODBC is Microsoft's strategic interface for accessing data in a heterogeneous environment of relational and non- relational database management systems.

Click on this button.This gives an active link with the Microsoft SQL Server

database. Any changes made in Access will be reflected in the SQL Server database.

A new DSN (data source name) Name has to be

created.

1. In this example it is:Oasis Instance Link. You

can choose any name you like.

2. Click on New

1. Scroll down and choose SQL Server

2. Click Next

1. Once again I chose Oasis Instance link.

2. Click Next

Click Finish

1. I have described the data source as Oasis

2. The server is alar\oasis

3. Click Next

2. Click Next

1. Use Windows NT Authentication

Choose your database as the default.

Click Next

Click Finish

Test the Data Source

2. Click OK

1. The result should read like this.

Click OK

1. You are now returned to the ODBC data source

window. Scroll through and choose the link to Oasis. In this example I set it up as

Oasis Instance Link.

Click OK

The tables from the default database should

now appear.

1. I highlighted the four tables I wanted to use.

Click OK

These four tables now appear in Access.

1. Table 1 can be deleted.

2. Click on Database Tools.

The relationships between the tables now have to be established

All tables are highlighted.

Add the tables to the Relationship window.

The relationships between the tables are

now established

Once the relationships are established, queries can now be created. A query will be created in order to produce a report.

Select the query wizard.

Close this window.

Right Click on Query 1 and select the SQL view.

This is the SQL view

SELECT c.CustomerNumber, c.CustomerLastName, iln.InvoiceNumber,i.SaleDate,sum(iln.QuantitySold * inv.SellingPrice) as Totalfrom dbo_CUSTOMER c, dbo_INVOICE i, dbo_INVOICE_LINE_ITEM iln, dbo_INVENTORY invwhere c.CustomerNumber = i.CustomerNumberand i.InvoiceNumber = iln.InvoiceNumberand iln.InventoryNumber = inv.InventoryNumberGROUP BY iln.InvoiceNumber, c.CustomerNumber, c.customerlastname,i.SaleDateORDER BY c.CustomerNumber, iln.InvoiceNumber

I want to produce a Sales Report

Notice the ‘dbo’ in front of each table name. The actual names of each table are

preceded by ‘dbo’

The SQL is structured in the same manner as SQL SERVER

To run the query

This query will now be used to generate a report using the Report Wizard.

Click on the Create Menu.

2. Run the Report Wizard.

1. Save the query

All lines will be selected. Click Next

A grouping by CustomerNumber

No sorting since the SQL already pre-sorted the

query.

Stepped lay out

The name of the report.

Click on the Design View to change the format of the

report.

I want to create a Sales Invoice

Notice the concatenation. Access uses ‘&’ instead of

CONCAT

The initial report looks like this.

Original Design View

The New Design View

The Invoice