473,915 Members | 7,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lots of queries for my db

Hello all,

I have a database in SQL Server that should save data from a CRM-like
application.

The database consists of tables like products, services, customers,
partners etc. Problem is that the users should be able to find these
items on different properties and with or without substring finding
(SQL: LIKE). Example: I want the users to be able to find a customer,
providing a customerID, but also providing a customername, zipcode or
just a part of those strings.

This will result in a lot of queries. I bet there are some nice
solutions to this, since I will not be the first with this situation.

If anyone can help, please.
Thank you in advance.

Regards,

Freek Versteijn
Jul 20 '05 #1
3 1734
This seems like the article for you:
http://www.algonet.se/~sommar/dyn-search.html

--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=d...blic.sqlserver
"Versteijn" <ve*******@538m ail.nl> wrote in message
news:4d******** *************** ***@posting.goo gle.com...
Hello all,

I have a database in SQL Server that should save data from a CRM-like
application.

The database consists of tables like products, services, customers,
partners etc. Problem is that the users should be able to find these
items on different properties and with or without substring finding
(SQL: LIKE). Example: I want the users to be able to find a customer,
providing a customerID, but also providing a customername, zipcode or
just a part of those strings.

This will result in a lot of queries. I bet there are some nice
solutions to this, since I will not be the first with this situation.

If anyone can help, please.
Thank you in advance.

Regards,

Freek Versteijn

Jul 20 '05 #2

One of the solutions is not a technical solution : it's a deeper analysis.
A great advantage of this solution is that the technical implementation will
be, we hope, simpler than an exhaustive research across all the columns of
the database.

The risk of an exhaustive implementation is an research that the users
will use only at 5% of its capacities (always quering on the 4 same
columns...).

I had implemented this kind of research program : it worked fine when it
returned 2 result lines, but too much often, it had returned thousand lines
!

For information, the main algorithm was (if my memory do not fail !) :
- ask to the user the value to search, and for string value only, if it is
an exact search or an "LIKE %s%" search ;
- detection of the type of value to search (char, interger, float, ...) ;
- research of the columns of this type (1 query in
INFORMATION_SCH EMA.COLUMNS) ;
- for each table with at least one matched column, 1 SELECT query :
- SELECT PK, fld1, fld2
- FROM the table
- WHERE fld1='value' OR fld2='value' OR ...
(or WHERE fld1 LIKE '%value%' OR ...)

* analyse the result recordset and display the results in a array, with
these columns : TableName, PKValueOfTheMat chedRecord, FieldName, FieldValue.

This program gives the right results, but it talks about "Table", "PK",
"Field", ... and it's not the user's language. So, the difficulty is to
transform these "data oriented" results in "users oriented" results !

I'm interested in an different approach.

Jacques.
"Versteijn" <ve*******@538m ail.nl> a écrit dans le message de news:
4d************* *************@p osting.google.c om...
Hello all,

I have a database in SQL Server that should save data from a CRM-like
application.

The database consists of tables like products, services, customers,
partners etc. Problem is that the users should be able to find these
items on different properties and with or without substring finding
(SQL: LIKE). Example: I want the users to be able to find a customer,
providing a customerID, but also providing a customername, zipcode or
just a part of those strings.

This will result in a lot of queries. I bet there are some nice
solutions to this, since I will not be the first with this situation.

If anyone can help, please.
Thank you in advance.

Regards,

Freek Versteijn

Jul 20 '05 #3
> The database consists of tables like products, services, customers,
partners etc. Problem is that the users should be able to find these
items on different properties and with or without substring finding
(SQL: LIKE). Example: I want the users to be able to find a customer,
providing a customerID, but also providing a customername, zipcode or
just a part of those strings.


Hi,

Without knowing the details about your DB, the following should work.
Assuming that there are no nulls in your key fields and they are set
as varchar/char. If they're integer, the query will do an implicit
conversion. Of course, the hard part is actually testing and
optimizing the queries. -- Louis

-- All the parameters should default to '%'
(to return all rows, unless the user passes a value)

select *
from mytable
where
customerID like @customerID
and customerID like '%'+ @customerIDfrag ment +'%'
and customername like @customername
and customername like '%'+ @customernamefr agment +'%'
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6801
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used the SQL Profile to watch the T-SQL-Command which Access ( who creates the commands?) creates and noticed:
1
2321
by: Roger Green | last post by:
I have inherited a complex database that has many dozens of queries that derive data from a people table. I now need to be able to run these queries (from within a significant number of forms) not on the full dataset, but on a subset of the data in the people table. I want to avoid having to put criteria in all of the individual queries or forms, or having to change the data source for all the queries. Is there anyway I can restrict...
3
2340
by: NeilAnderson | last post by:
I'm a fairly new user of access & I've never had any training, so I'm wondering if I'm doing the right thing here, or if it matter at all. I'm building a database for room booking purposes and I'm trying to do all record changing using queries. From what I can glean from this (excellent!) group this is the right way to go about it. At present what I'm doing is building & trouble-shooting the queries with query-builder then using code to...
2
1926
by: Darryl Kerkeslager | last post by:
As the subject above hopefully makes clear, I want to do several reports, "with lots of fields not otherwise in database". These reports also have variable-length text. I have defined the following options (all users have Office 2000): 1. All Access solution. This appears to involve creating forms to enter data that is just put into a report, and never saved - an exercise in wasted development time, to my thinking. Also, the...
44
4607
by: Greg Strong | last post by:
Hello All, Is it better to create a query in DAO where a report has 4 sub-reports each of whose record source is a query created at runtime and everything is in 1 MDB file? From what I've read and experienced it appears DAO is the way to go in this situation, so when is it good to use ADOX to create queries? Why do I ask the question? I've created a MDB file which uses DAO, but
6
1222
by: Jack | last post by:
Hi there, I'm not sure if this the appropriate group so apologies if it lies outside the boundary. Senario: I have a customer table with contains a bunch of different bit values that represent true/false values pertaining to the customer. I decided for the purpose of clarity I would move these values into another table. This way I would keep the customer details (name, age, etc) separate from these values. Question: Is this a good...
2
3830
by: saran | last post by:
I am having a problem with MySQL consuming a lot of memory and eventually throwing an Out of Memory error and restarting itself. The symptoms are that swap usage continues to rise until some breaking point. The application is a typical web application w/ 2 web servers running Apache/Tomcat connecting to a dedicated DB server running only MySQL. This seems to occur as a result of running many statements in a single transaction, both...
2
2115
by: TD | last post by:
Hello All- We are in the process of converting the back end of our large MS Access application to PostgreSQL. My question today concerns linked tables and how their connections are managed by Access. It appears that Access does a *lot* of connecting and disconnecting to these linked tables. This is causing me a major headache, as I'd really like to store some session-based information in the back end that can be referenced by the linked...
5
5566
by: listerofsmeg01 | last post by:
Hi, Pretty new to PHP and MySQL. I have a page on my site that displays a lot of information from various tables. Currently I have lots of small PHP wrapper functions around SQL queries to get each bit of information. This results in maybe 10 queries to display one page, but they are all very small and simple, and it keeps the PHP looking nice too as they are simple function calls to get each piece of info, which can be called from any
0
10928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7259
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.