Microsoft KB Archive/149670

= How to Run Multiple SQL Statements with the VFP ODBC Driver =

Article ID: 149670

Article Last Modified on 8/8/2000

-

APPLIES TO


 * Microsoft Open Database Connectivity Driver for Visual FoxPro 1.0

-



This article was previously published under Q149670



SUMMARY
To run multiple SQL statements with one SQL Pass-Through command, you can place a semicolon between the two SQL commands. This article demonstrates how to execute multiple SELECT statements from Microsoft Access for Windows 95 version 7.0 to a Visual FoxPro 3.0 table by using the Visual FoxPro ODBC driver.



MORE INFORMATION
This example selects data from the Customer and the Orders tables located in the Tastrade directory. It returns two sets of data and creates two tables in a Microsoft Access database.

Step-by-Step Example
 Using the Visual FoxPro ODBC Driver, create a data source to the Visual FoxPro Tastrade database located in the Samples\Mainsamp\Data directory.

 Start the ODBC Driver Manager. Click the Add button to add a driver. In the list of drivers, select the Microsoft Visual FoxPro Driver. In the data source dialog box, click the Visual FoxPro Database (.DBC) as the database type. Select Tastrade.dbc, located in the Samples\Mainsamp\Data directory.</ol> </li> Start Microsoft Access version 7.0 and create a new database.</li> In the Database window, select the Query tab to create an SQL Pass Through (SPT) query.

<ol style="list-style-type: lower-alpha;"> Click the New button.</li> In the New Query box, select Design View and click OK.</li> In the Show Table box, click Close to close the dialog box (without adding a table or query). Note that you are now in Query Design view.</li></ol> </li> On the Query menu, point to SQL Specific, and click Pass-Through.</li> In the SQL Pass-Through window, type the following SQL statement, which will create two result sets:

SELECT * FROM customer; SELECT * FROM orders

</li> Close the query and save it as Qrymultiple.</li> You then need to create a MakeTable query based on the SPT query.

<ol style="list-style-type: lower-alpha;"> In the Database window (Queries tab), click New.</li> In the New Query box, select Design view and click OK.</li> In the Show Table dialog box, click the Queries tab, select Qrymultiple, and then click Add.</li> In the Query grid, select "*" in the Field row of the first column to include all the fields in the query.</li> On the Query menu, click Make Table. In the Make table dialog, type the name Tbltest and ensure that the Current Database option is checked. Click OK.</li> Close the query and save it as Test1.Save the query and close it.</li></ol> </li> Open the Test1 query. A warning is displayed. Click OK.</li> <li>After the query is run, click the Tables tab. Note that two tables should have been created.</li></ol>

Additional query words: 1.00 vfoxwin 3.00 3.00b

Keywords: KB149670

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.