Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing multiple SQL Statements

Status
Not open for further replies.

mike718

Programmer
Jul 7, 2004
58
US
I was wondering if there was a way to run multiple SQL Statements in Access like you can in SQL. I have a bunch of steps that I would like to combine in one script.

Thanks

Mike
 
You can run a query in a query, if that helps. I have a query called qryCollision that is called in the query below. If you use the design grid you can add an existing query as you would a table.

the sql view looks like this where qryCollision is another query (sql statement) which i what i think you want.

SELECT tblResources.ResID, qryCollision.Surname, qryCollision.Firstname, qryCollision.TelExt, qryCollision.StartDate, qryCollision.EndDate
FROM qryCollision RIGHT JOIN tblResources ON qryCollision.ResID = tblResources.ResID
WHERE (((tblResources.ResID) Not In ([qryCollision]![ResID])));
 
Separate the SQL with a semi colon ;

Dim cn as New ADODB.Connection
Dim aString as String

aString = "select * from table1;select * from table2"

cn.Execute aString
 
I assume that ... like in SQL ... means stored procedures in SQL server. There are no direct equivalents in Access. You can do what jaydeebe and cmmrfrds suggest or you can write modules (VB Code) to combine SQL statements and logic. They don't operate exactly the same way that stored procedures do but they do provide more options than are available with SQL alone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top