Solved

Need help writing a Pass Through Query in A2K

Posted on 2014-11-30
9
62 Views
Last Modified: 2015-02-15
Hello,

I'm running an application written in Access 2K.
It has a split front/back end.

My InternetData table is on a MS SQL server
My Parts4Sales and ComponentMaster tables are Access mdb files.

The following query appends about 250,000 records and takes about 20 minutes to run.  I need to speed it up.
I've been told I need to create a stored procedure or a pass through query.

First question, is this possible in as only one of the tables is on the MS SQL server
Second, if yes, will I get better performance out of the stored procedure or pass through?
Third, how can I find out how the SQL table is connected to the database.  I set it up myself, but it was years ago.
0
Comment
Question by:pcalabria
  • 5
  • 3
9 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 40473008
I think you have forgotten to attach the query.
1. It depends what you need to pass to the stored procedure as parameters. If you need to pass just values then it is possible to use The stored procedures. However, if your append query appends data directly from a SELECT statement from an Access table, I do not think you will get much performance improvements. As I said before, please show us your existing query, which indirectly answers your second question
3. You can find this information simply by looking at the "Linked table Manager". In Access 2000 this option is under Tools->Database Utilities->Linked Table Manager
0
 

Author Comment

by:pcalabria
ID: 40473019
opps... here we go:

INSERT INTO InternetData ( OriginCode, LotCode, DateCodeAll, PartID, HouseNumber, ProjectHouseNumber, TrackingNumber, Description, PartClass, PartFamily, PartMarking, GenericNumber, Package, RecPrice, FullPacks, TrayQty, DocName, code, PackageQty, PackageType, Condition, ConditionCategory, PbookPrice, quantity, Manufacturer, SalesNote, Notes, LineID, [Value], Tolerance, FullReelQty, ReelSize, TapePitch, TapeWidth, CaseSize, TCR, Power, Voltage, OperatingRange, MSL, EURoHS, Pb, SearchNumber, OrderNumber ) SELECT Parts4Sales.OriginCode, Parts4Sales.Lotcode, Parts4Sales.DateCodeAll, Parts4Sales.PartID, Parts4Sales.HouseNumber, Parts4Sales.ProjectHouseNumber, Parts4Sales.TrackingNumber, ComponentMaster.Description, ComponentMaster.PartClass, ComponentMaster.PartFamily, ComponentMaster.PartMarking, ComponentMaster.GenericNumber, ComponentMaster.Package, Parts4Sales.RecPrice, Parts4Sales.FullPacks, Parts4Sales.TrayQty, ComponentMaster.DocName, ComponentMaster.code, Parts4Sales.PackageQTY, Parts4Sales.PackageType,
Parts4Sales.Condition, Parts4Sales.ConditionCategory, ComponentMaster.PBookPrice, Parts4Sales.Quantity, ManufacturerMaster.ShortName AS Manufacturer, Parts4Sales.SalesNote, ComponentMaster.Notes, Parts4Sales.LineID, ComponentMaster.Value, ComponentMaster.Tolerance, ComponentMaster.FullReelQty, ComponentMaster.ReelSize, ComponentMaster.TapePitch, ComponentMaster.TapeWidth, ComponentMaster.CaseSize, ComponentMaster.TCR, ComponentMaster.Power, ComponentMaster.Voltage, ComponentMaster.OperatingRange, ComponentMaster.MSL , ComponentMaster.EURoHs, ComponentMaster.Pb, Parts4Sales.searchNumber, ComponentMaster.OrderNumber FROM (Parts4Sales LEFT JOIN ComponentMaster ON (Parts4Sales.LineID = ComponentMaster.LineID) AND (Parts4Sales.SearchNumber = ComponentMaster.SearchNumber)) INNER JOIN ManufacturerMaster ON Parts4Sales.LineID = ManufacturerMaster.LineID WHERE (((Parts4Sales.SearchNumber) Is Not Null And (Parts4Sales.SearchNumber)<>''));
0
 

Author Comment

by:pcalabria
ID: 40473105
So the question is, is there a way I can speed up the above query.  When running as an Access query, it takes about 20 minutes to run with 250,000 records.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40473294
All tables are in SQL Server? If not, which ones are and which ones not?
There's an index on Parts4Sales.SearchNumber? If not, you should create one for this query.
There's an index on ComponentMaster.SearchNumber? If not, you should create one for this query.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:pcalabria
ID: 40473475
<<InternetData table is on a MS SQL server>>
<< Parts4Sales and ComponentMaster tables are Access mdb files.>>

The query is run from the an Access 2K front end, off an XP Pro workstation.
Both mdb files are on a Windows 2000 Server
The InternetData table is on a different workstations which is running MS Server 2008 ( I think its R2, its a paid version)

LineID in all tables is numeric, and it is indexed
Searchnumber in all tables is string, and it is also indexed

There are about 250,000 records in the query
When I convert to a select query and run it in the query builder I see results in about 3 seconds.  When I then hit end to see the last record it takes about 30 seconds.

One of the other experts suggested I use a stored procedure or pass through, but I don't know how to do that so have not tried.  It would think that since all the data is not on the SQL server, it may be complicated.

If anyone can help it would be greatly appreciated.   I'm trying to get this working before the staff arrives at work in another hour! :-(
0
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40473490
When I convert to a select query and run it in the query builder I see results in about 3 seconds.  When I then hit end to see the last record it takes about 30 seconds.
That's because Access only shows you part of the information. If you go to the last record he needs to load all data and that's why takes longer.

One of the other experts suggested I use a stored procedure or pass through, but I don't know how to do that so have not tried.  It would think that since all the data is not on the SQL server, it may be complicated.
Impossible I may say since there's no stored procedures in MS Access.
0
 

Author Comment

by:pcalabria
ID: 40473990
Thanks for the comments.

I mention that the select query can display all of the records in 30 seconds because it seems odd that I can pull 250,000 records in 30 seconds from Access MDB tables, but when I change the query to an APPEND query and append the same data to an MS-SQL server, it takes 20 minutes.

Doesn't  that seem strange to you?

Anyone that can help, please chime in!  Thanks Victor and Chaau.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 40475380
I don't work with Access for long. What do you mean with APPEND? It's a SELECT INTO?
0
 

Author Closing Comment

by:pcalabria
ID: 40610740
Thanks
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now