view multiple Queries' SQL statement

  • Thread starter Thread starter SQL novice
  • Start date Start date
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?
 
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
 
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?
 
if you're doing this in SQL Server, then you can just look in the
syscomments table.

-aaron
 
Back
Top