troubleshooting Question

Returning results from search page using SQL Server 2000

Avatar of alexisbr
alexisbr asked on
Microsoft SQL Server
4 Comments1 Solution275 ViewsLast Modified:
Hi.  I am trying to figure out a way to return results to users searching for data in an Access 2010 frontend (created in Access 2003) that has a SQL Server 2000 backend.  The backend is a data warehouse that will eventually have lots of data.  Right now there are only about 4,000 master records and 40,000 detail records.

Users will be selecting materials from a dropdown and then I need to return SampleIDs that use the materials selected.

Below is a small sample of how the data looks.  The real tables have many more rows per SampleID and many materials.  But, like the sample data, there are 2 different material fields (used for different purposes in the database) that I need to look at in each row for the purposes of this search project.

MasterID is the key in the first table and DetailID is the key in the second table.  The two tables are related by MasterID.  

Here are two examples:  
1. A user selects materials AA and DD from the list (they can select up to 4 materials).   I need to return sampleID 6-123 as the only sampleid that uses those materials.

2. A user selects material WW from the list.  I need to return sampleIDs 4-234 and 6-123 since they both use WW.

I wrote SQL code to take all the materials in the normalized detail table and concatenate all the materials (possibly 2 per row but with many rows) and put all that data as one line per SampleID in a pre-processed table.

For example:
SampleID      MaterialsList
4-234            AA,XX,WW,QQ,DD,TT
6-123            EE,FF,AA,BB,WW,XX,QQ

Then I could do a “like” in the search but the program to create the data above takes a while to run from SQL Agent.  When I run it in the Query Analyzer, takes less than 40 seconds but from the SQL Server Agent with a stored procedure, it isn’t even finished after 5 minutes.  So the first problem using the SP to create stored data I can search from is that I would have to run this process on a regular basis and the data would never be current to the moment unless the process just ran.  The second problems is that using a ”like” operator means the process to return search results may be slow.  We will eventually be upgrading to a later version of SQL Server and a much faster server but, for now, this is what we have to work with.

Then I thought that there may be a way to get this logic to run without using pre-processed data.   I am working on that now.  I tried using a select with a subselect to get the materials but that won’t work because multiple materials are returned from the subselect.

I hope my explanation makes sense.  Does anyone have any suggestions?

 Sample data
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros