view multiple Queries' SQL statement

S

SQL novice

I need to review the SQL statements of queries in Microsoft Access. I am
opening each one individually. Time consuming and tedious. Is there a way I
can download these queries and only their SQL statement to one table, excel
or word doc?
 
S

Sylvain Lafontaine

Here's a way to collect the text information for all queries into a text
file (this must be executed from a MDB file):
Public Sub WriteQueries()


Dim intFile As Integer
Dim db As DAO.Database
Dim qdfs As DAO.QueryDefs
Dim qdf As DAO.QueryDef


intFile = FreeFile
Open CurrentProject.Path & "\queries.text" For Output As intFile
Set db = CurrentDb
Set qdfs = db.QueryDefs


For Each qdf In qdfs
Print #intFile, qdf.Name
Print #intFile, qdf.SQL
Next qdf


Close intFile
End Sub
 
Y

yangxianfa

SQL novice said:
I need to review the SQL statements of queries in Microsoft Access. I am
opening each one individually. Time consuming and tedious. Is there a way
I
can download these queries and only their SQL statement to one table,
excel
or word doc?
 
A

a a r o n . k e m p f

if you're doing this in SQL Server, then you can just look in the
syscomments table.

-aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top