Home Case Studies MS Office Tips and Tricks Sample Code Helpful Videos Custom Development  Custom Training Join Us Contact Us
Search Our Site:  

Using SQL In Access

If you already know SQL you probably feel constrained by the Query Builder in Access. But you don’t have to be. Open a new query in Access and when you’re asked to select the tables your query will be based upon, just close the window.

You will notice at this point that the toggle button which usually shows Design View or Datasheet View now shows SQL. Feel free to type SQL directly into this window. If you already have a query, you can still open the SQL view -- it is always available.

   

click the image for a video of this functionality

The SQL view is important because there are some types of queries which you cannot build graphically. It leads many of us to assume that they cannot be run in Access. This is incorrect. One example is the UNION query. As you know, a JOIN combines tables vertically. In other words, you choose columns from one table and combine them with columns from another table. The UNION query combines rows from one table with rows from another table. For an example see the Northwind database installed with Microsoft Office under the query Customers and Suppliers by City.

Another powerful tool is the Pass-Through query. If you need data from a SQL Server database or an Oracle database and it needs to come from a stored procedure, you can use the Pass-Through query to call the stored procedure on the server. Access doesn’t understand stored procedures, but it can hand off the name to a server that does and receive the recordset that is generated.


Are You Ready For Office 365?


Office 365 is

  • Email and calendaring powered by Microsoft Exchange
  • Office Web Apps - the office productivity apps you already know, tailored for the web
  • Websites powered by Microsoft SharePoint both for internal-facing intranet and customer-facing website
  • Instant Messaging and Online Meetings powered by Microsoft Lync
  • All with a financially-backed 99.9% uptime guarantee

Sign up for a free trial:

Name
Company
Email Address

Your information will not be shared with any other party. You must provide a valid email in order to recieve your login information and starting information kit.

Watch this video  to see how Office 365 can help your business.

It can be difficult to find other SQL specific keywords like DISTINCT or TOP. These can be found by a right clicking in the query window and choosing Query Properties as shown below.

 
click the image for a video of this functionality

If you want to use the SQL keyword SELECT DISTINCTROW, you would choose unique records and set the value to yes. For the SQL keyword SELECT DISTINCT you would choose unique values and choose yes. For TOP values or percentage you would choose Top Values and choose either a number or a percentage.

See the Tips and Tricks section of the I Get It! Development website for a video demonstrating how to use this functionality.

Whether you type your SQL, or use the query builder to add in SQL for you, remember that you do have a much more complete library of SQL to use in Access.


 
Please share your comments on this article!

 
Name (opt)
Email Address (opt)
Your Questions/
Comments

I Get It! Development does not share your email address or other information, nor do we add you to any mailing lists unless you specifically request to be added by checking the box below.



SEE ALSO
You may also find the following articles useful:

Subqueries In Access

SQL Cross Join In Access

Access And Uses For Union

One-To-One Relationships In Access

Exotic Joins In Queries

Spreadsheet vs. Database

Bound vs Unbound Forms

Excel - Access Import Problems

Columns In Access

Spreadsheet View (Access)

Access To Excel And Back

VBA Functions In Access

Ssheets vs Dbase Round 2

Control Your Data!

Compact/Repair In Access

References

Journal of Accountancy Articles

Tweaking The Numbers

Block That Spreadsheet Error

Excel Security Issues


 

Clients

Do you need help with Microsoft Office? Contact us

See how we've helped companies like yours develop effective business processes

Client Success Stories


 

Consultants

I Get It! Consultants set their own hours, work with their own clients, and choose their own projects.

If you're a Microsoft Office guru and would like to explore being a full-time consultant, please see our consultant information pages.