English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How can I export the SQL of my queries? When I right click a query and select 'Design View', then right click the top frame and choose 'SQL View' I get the SQL of the query. Its this that I need to export. I have quite a lot of queries that I need as SQL and it would take quite a lot of time to copy and paste and save them as SQL manually.

2006-12-06 01:37:44 · 2 answers · asked by Neil 1 in Computers & Internet Programming & Design

2 answers

I built a little function for you for outputting all the SQL of the queries within your database. Insert the following sub into a module and open your immediate window (ctrl-g?). Add a reference to the Microsoft DAO Object Library if needed.

Public Sub IterateQueryDefsCollection()

Dim dbMain As DAO.Database

Dim qdf As DAO.QueryDef
Dim qdfTemp As DAO.QueryDef

Set dbMain = CurrentDb

For Each qdf In dbMain.QueryDefs
Debug.Print qdf.Name 'Prints name of query
Set qdfTemp = dbMain.QueryDefs(qdf.Name)
Debug.Print qdfTemp.SQL 'Prints SQL Syntax of query
Next

End Sub

Once you have run this, all the SQL should be in your immediate window, just copy and paste to a text file.

Hope that helps! Been there, I build most of my SQL from the Access designer also.

2006-12-06 03:22:07 · answer #1 · answered by Special Ed 5 · 0 0

Access 2010 Sql View

2016-12-17 12:57:28 · answer #2 · answered by bate 4 · 0 0

fedest.com, questions and answers