Multiple queries - the scenario

An automated inspection system checks each part for defects and stores the result in a Microsoft SQL Server database.

Each part that is tested is logged to a table named LOG_ALL.  The part number (type of part), serial number of each part, date/time stamp when the inspection took place, and ID number of the inspection station are logged in this table each time a part is inspected.  The inspection results are also logged to this table, noting "P" for "Pass" and "F" for "Fail".  A final column, "Processed", tracks whether each record has been logged into GainSeeker.

For each part that fails inspection, one or more records are created in a second table named LOG_FAIL.  In this table, the same part number, serial number and date/time stamp as those used in the LOG_ALL table are used to identify the part.  However, each record in the LOG_FAIL table also logs the type of defect found on the part.  If multiple defects were found on the part, multiple records for that part's serial number will be added to the LOG_FAIL table.

An example of the two tables and their relationship to each other is shown here:

 

More:

Using the Database Integration Wizard

Working with multiple SQL statements