Implementing A Simple Search

Mar 26, 2008

I'm not trying to do anything too fancy; given a string, I just wanna see if anything in the column of my database matches the string.  I'm using an SQL query that takes a string, then selects the data using LIKE %searchword%.
This works fine when the user enters only one word.  But I guess you can see that a problem arises when they enter more than one word.
So how can I implement a very simple search that will take more than one word?
 

View 5 Replies


ADVERTISEMENT

Implementing A Search

Mar 28, 2008

Here's my table:

----------------------------
News
----------------------------
ID | Headline | Article
----------------------------


I want the user to be able to search for keywords in articles. Here's my stored procedure:

CREATE PROCEDURE sproc_GetNewsSearch
(
@keyword varchar(50)
)
AS
SELECT Headline, Article
FROM News
WHERE Article LIKE '%' + @keyword + '%'

This will work fine if I search with one word. If I enter "zebra", it will find the articles containing "zebra".

The problem is when I search for more than one word. If I enter "monkey zebra", it won't search for articles containing "monkey" and "zebra", it will look for "monkey zebra".

How can I fix that?

View 6 Replies View Related

Implementing A Simple Data Dictionary Via Extented Properties

Jun 25, 2007

Hi,



I'm thinking of implementing a rudimentary Data Dictionary for a database using extended properties to store table and column descriptions.

Does having this information for every table and column in a database (200 tables; 2000 columns) cause any (negative) impact on database performance? I'm guessing it shouldn't but want to make sure before implementing this in the production environment.



Thanks,

Smitha

View 3 Replies View Related

T-SQL (SS2K8) :: Implementing Full Text Or Universal Search Facility In Website

Nov 6, 2014

How to implement a universal search in my site And it must be give result precised up to 90%.

Scenario is like that whenever customer come to our site he/she can search for example: Car parts

My Table structure is like below:

Column 1 Column 2 Column 3 Column 4 column 5 column 6 (Keyword)
Toyota camry 2000 wheel ABC123 Toyota camry 2000 wheel abc123
Toyota camry 2000 wheel cover 123 Toyota camry 2000 wheel cover 123

Now i have created a full text search index on column 6(keyword)

so whenever someone search exactly describe in column 6 it gives result

For ex: if i search (Toyota Camry wheel) with CONTAINS Option

Select * from mytable where Contains
(Keyword,'Toyota and Camry and wheel')

It gives me rows which contains Toyota Camry wheel and other rows which having wheel cover also. So i get multiple rows. Because of we have very large table which contains data in millions its not to feasible to have that thing.

another thing is :

if i search (Toyota Camry wheels) with CONTAINS Option
Select * from mytable where Contains
(Keyword,'Toyota and Camry and wheels')

It won't give any result back to me which is embarrassment for me. Because customer can search anything so if its not giving result its bad impression.

Also i tried to use FREETEXT option but it gives result in combination of all this word which i searched. so its huge amount of data in result.

View 2 Replies View Related

Simple SQL Search

Jul 11, 2006

Hi, Im trying to create a simple search page to return a list of products from a table in a sql database. Id like to be able to search a product description column in a table I have called products using the contents of a text box. I was wondering how i can go about getting the search to check for all words the user types in rather than just a single word or an exact phrase. Im currently using the following sql query
SELECT [product_title], [product_description] FROM [products] WHERE ([product_description] LIKE '%' + @product_search + '%')
this works fine for single words and exact phrases but if i had product called 'fred w bloggs' and i enter 'fred bloggs' it will not return anything.
Please could anyone suggest how i shoud go about this?
Im not sure if my web hosting company will enable full text search or will this be required?
Thanks for any help!
pete_ (very new to asp.net!)

View 1 Replies View Related

A Simple Search

Feb 10, 2008

Hi all I need to implement a search function in Asp.net. Its nothing complicated, just find out whether a value exists in a particular table and return a boolean accordingly. However, the table has about 300,000 records. Is simply querying the table from the web (SELECT barcode FROM tblProducts where ID=123) the best way considering the releant column has been indexed.Any pointers would be appreciated. Thanks   

View 4 Replies View Related

Simple Search Help

Mar 16, 2008

Hello new in sql and asp.net here.I have this Select * from InvoiceHeader where TransactionDate > '03/16/2008' That code isn't working instead of returning a row with a transaction date that is greater than 3/16/2008 what it return is all the row. How can  fix this? Thanks! 

View 9 Replies View Related

A Simple Search

Mar 24, 2008

I have a table of articles:

-------------------------------------
Articles
-------------------------------------
ID | Date | Headline | Body
-------------------------------------

I'm trying to write a stored procedure that will search for a given keyword. Here's what I have:

CREATE PROCEDURE sproc_SearchArticles
(
@keyword varchar(50)
)
AS
SELECT ID, Date, Headline, Body
FROM Articles
WHERE Body LIKE %@keyword%
ORDER BY Date DESC
RETURN


That keeps giving me an error. If I put quotes around it, it will literally look for the term @keyword anywhere in the body.

View 1 Replies View Related

Simple Search Query

Mar 16, 2007

Hi,

 

I'm writing
small search engine for my page. I need SQL query that could do this:

 

Source:

 

tblColours

------------

Red

GreenRed

White Red

Yellow

Blue Green

Yellow RedF

 

Search
string: Red

 

Required
results:

 

Red

White Red

Yellow RedF

 

As you can
see I need all occurrences of word Red and word Red* but I don’t need *Red or
*Red* so I can't use LIKE %Red% :(.

 

P.S. Sorry
for my English.

Fizikas.

View 1 Replies View Related

Simple Search Page

Feb 1, 2008

 Hello all, I am trying to build a simple search page using SQL Server 2005, Visual Web Developer in C#.I have enabled Full-Text Search on my DB and created the catalogs and indexes, but I am lost on the next step to build a search form that calls the data based on the users input in a textbox. Any suggestions? Thanks!Travis 

View 3 Replies View Related

Help Simple Search Date

Mar 28, 2008

hello I have this code Select Waste.WasteName AS [Waste Name], InvoiceDetail.Volume, Branch.BranchLocation AS [Branch Location] From InvoiceHeader INNER JOIN InvoiceDetail ON InvoiceHeader.InvoiceNo = InvoiceDetail.InvoiceNo INNER JOIN Waste ON InvoiceDetail.WasteID = Waste.WasteID INNER JOIN Branch ON InvoiceDetail.BranchID = Branch.BranchID Where WasteName = 'Sludge' AND InvoiceDate >= '" + TextBox1.Text + "' AND InvoiceDate <= '" + TextBox2.Text +  "'; The problem is everytime I will search for example InvoiceDate 03/27/2008, I need to add one day for example --> 03/28/2008 for me to be  able to get that Invoicedate 03/27/2008.. What's do you think is the problem with my code?  Thanks!  

View 9 Replies View Related

Wildcard In Simple Sql Search.

Mar 30, 2005

I'm very new to SQL so please forgive my ignorance...
I've made a simple .net search page which queries an sql database with the following query, (in a stored procedure):
SELECT     Category, Number, RegisteredUser, DeptName, Surname, Forename, Site, IDFROM         tblTelephonesWHERE     (@surname IS NULL OR                      Surname LIKE @surname) AND (@site IS NULL OR                      Site = @site) AND (@deptname IS NULL OR                      DeptName LIKE @deptname)
This works fine, as expected if i leave fields null or enter an exact match, but I (of course) have to add a wildcard in my search string for a wildcard search. For example, looking for 'duncan' i need to enter 'du%' or 'duncan'.
What I really want is for all searches to have wildcards behind them so only the first few characters need be inputted, and I could just search for 'd' or 'dun' without adding the '%' to get 'duncan'. I think I am aware of the implications of this approach and do want to go ahead as there are only about 850 records.
Any help or links to useful articles would really be greatly appreciated.

View 1 Replies View Related

My First ASP.NET (simple) Search Page For SQL

Mar 30, 2005

This question probably applies to Visual Web Developer but I don't know if it belongs in this Forum or that, sorry if you have to move it.
Hi there kind person reading this
I've created a stored procedure in SQL2000 that selects records where (name = @name) AND (site = @site). It works as I have tested it with Enterprise Manager.
I have also created a page with VWD that has a drop-down list populated with the site records and a text box. I have put an SQL data source on the page that is configured to select from the stored procedure. However, I can't set the @name and @site variables to collect from the ddl and txtbox through the wizard! I've tried selecting a Control as the source for @site but neither the ddl or txtbox appear in the control dropdown list. So  I want to crack it with handwritten code.
Does anyone know of a post or article that can help me link the ddl and txtbox to a search button, which calls the stored procedure with the chosen variables allowing me to put the returned data into a gridview? I've been through a great walkthrough for VWD (Student Activities) but it doesn't seem to apply to the latest version - or there's something wrong with my (seems fine though) instalation. Thanks if you can help, I owe you a

View 3 Replies View Related

Problems With A Simple Search

Apr 15, 2008

I have a table of news articles:


-------------------------------------
Articles
-------------------------------------
ID | Headline | Article
-------------------------------------


I'm trying to write a search function that will search through the text in the Article column. Here's my stored procedure:


ALTER PROCEDURE sproc_SearchNews
(
@keyword varchar(50)
)
AS
SELECTID, Headline, Article
FROMArticles
WHEREArticle LIKE '%' + REPLACE(@keyword, '%20', '%') + '%'
RETURN


There's a few problems with this however...
1. If I enter "Dog" into the search, it will skip over the article if it contains "dog". I need to convert the search term and the article text to lowercase.
2. If I enter "iron" into the search, it will find articles containing "iron", but it will also find articles containing "environment". How can I fix that without affecting my multiple word search in the WHERE clause?

View 3 Replies View Related

I Need A Simple Search Query

Jan 13, 2008

I have a table that has these columns:

LinkID, LinkURL, TimesRedirected

I have a webpage that keeps track of the url's of where the users are coming from. When they redirect to the page, the page will:

If the url of the previous page isn't in the database, add it
Otherwise, add to the TimesRedirected column.

View 6 Replies View Related

How To Create This Simple Database Search? Thank You.

Dec 7, 2004

Hello,

I have a search form in an ASP.NET/VB page. The form has the input text box and the button "search". The keywords are passed in the URL to results.aspx.

Here is an example of what I get in the URL, when I write the keywords "asp", "book" and "london" in the input text box and click "search":
results.aspx?search=asp%20book%20london

The database table has 3 fields: "id", "title" and "description".

I want to display all the records where at least one of the keywords is found in any of the 2 fields "title" and "description".

1. I suppose I need to get the words out of the URL to be used by SQL.
Maybe: string[] searchString = request.queryString("search").split('search'); ???
How can i make this run when page loads? I supose i need it. Right?

2. How should the SQL look? I supose i need to use the "Like" command
SELECT * FROM books WHERE title LIKE ...
But how to I use it if I can have 1, 2, 3, ... keywords?

Can someone help me?

Thanks,
Miguel

View 1 Replies View Related

Simple Search Engine (windows Application)

Sep 14, 2005

I'd like to build a simple search engine against Sql Server. Does .NET Framework provide some class to help in this task? From what I've heard there is an interface which implements it..

View 1 Replies View Related

Query To Search All Fields In Simple Table

Mar 1, 2006

I am trying to write a simple search page that will search all the fields in a database to find all records that match a user input string.  The string could happen anywhere in any of the fields.  I have a dataset and can write a query but am unsure what the format is for this simple task. I figured it would look like this:
 
SELECT Table.*
FROM Table
WHERE * = @USERINPUT 
But thats not working.  Can someone help.?  Thanks..

View 1 Replies View Related

Can Anyone Write A Simple Query To Search For NULLs

Apr 30, 2008



Hello ALl, can anyone please tell me how to search for NULLS.

like i know one method....

select * from table
where col = 'NULL'

View 1 Replies View Related

Simple Text Processing E.g. Regex Search And Replace

Aug 8, 2006

I've got an nvarchar(max) column that I need to transform with some simple text processing: insert some markup at the very beginning, and insert some markup just before a particular regular expression is matched (or at the end, if no match is found).

Since the SSIS expression language doesn't support anything like this, is a Script Component the only way to go? Does Visual Basic .NET provide regular expression matching?

Thanks!

View 13 Replies View Related

Simple Function For Returning A Character Based On Search Criteria..

Feb 20, 2007

Hi,how do I do a simple formula, which will search a field for specialcharacters and return a value.If it finds "%" - it returns 1elseIf it finds "?" it returns 2endIf this is the incorrect newsgroups, please direct me to the correct oneregards Jorgen

View 2 Replies View Related

SQL 2000 MS Search: Boolean Search Doesn't Work When Search By Phrase

Aug 9, 2006

I'm just wonder if this is a bug in MS Search or am I doing something wrong.

I have a query below

declare @search_clause varchar(255)

set @Search_Clause = ' "hepatitis b" and "hepatocellular carcinoma"'

select * from results

where contains(finding,@search_clause)

I don't get the correct result at all.

If I change my search_clause to "hepatitis" and "hepatocellular carcinoma -- without the "b"

then i get the correct result.

It seems MS Search doesn't like the phrase contain one letter or some sort or is it a know bug?

Anyone know?

Thanks

View 3 Replies View Related

Need Help--implementing Functions In C#???

May 5, 2008

Hi y'all I think i have some problem in here perhaps you guys can help.I have this code: 1 public void AddQstrWhere(ref string TmpStr,string Parameter)
2 {
3 if(TmpStr=="")
4 {
5 TmpStr +="WHERE"+Parameter;
6 }
7 else
8 {
9 TmpStr +="AND"+Parameter;
10 }
11 }
12
13
14 public string querySlsPerson;
15 //public string queryLastSls;
16 public ArrayList CLSGetSalesman(string szSalesmanID)
17 {
18
19
20 // TODO: Add CLSReportManager.CLSGetSalesman implementation
21 BOSTx Tex = GetTx(CLSReportConstants.TrnMasterID.FQN2,"QueryRptSales");
22 try
23 {
24 string querySalesPerson = "SELECT dbo.BOS_GL_Workplace.WpszState, BOS_PI_Employee_1.szName, dbo.BOS_PI_Employee.szName AS Expr1, dbo.BOS_PI_Employee.szEmployeeId, "+
25 " dbo.BOS_PI_Division.szName AS Divisi, dbo.BOS_PI_Team.szDescription "+
26 " FROM dbo.BOS_PI_Employee LEFT OUTER JOIN "+
27 " dbo.BOS_GL_Workplace ON dbo.BOS_PI_Employee.szWorkplaceId = dbo.BOS_GL_Workplace.szWorkplaceId LEFT OUTER JOIN "+
28 " dbo.BOS_PI_Division ON dbo.BOS_PI_Employee.szDivisionId = dbo.BOS_PI_Division.szDivisionId LEFT OUTER JOIN "+
29 " dbo.BOS_PI_Team ON dbo.BOS_PI_Employee.szTeamId = dbo.BOS_PI_Team.szTeamId LEFT OUTER JOIN "+
30 " dbo.BOS_PI_Employee BOS_PI_Employee_1 ON dbo.BOS_PI_Employee.szSupervisorId = BOS_PI_Employee_1.szEmployeeId ";
31 //"WHERE dbo.BOS_PI_Employee.szEmployeeId = '"+szSalesmanID+"'";
32 //" WHERE BOS_GL_Workplace.WpszState = '" + szProvince + "' AND BOS_PI_Employee.szName = '" + szsalesPrsn + "' AND BOS_PI_Employee_1.szName = '" + szSupervisor + "'";
33
34 string wheretext = " dbo.BOS_PI_Employee.szEmployeeId = '"+szSalesmanID+"'";
35 string queryLastSls;
36 //AddQstrWhere(szSalesmanID,wheretext);
37 if(szSalesmanID==string.Empty)
38 {
39 queryLastSls = querySalesPerson;
40 }
41 else
42 {
43 //string querySlsPerson;
44 AddQstrWhere(ref queryLastSls,wheretext);
45
46 queryLastSls = querySalesPerson + querySlsPerson;
47 }
48
49 OleDbCommand comd = Tex.GetTextCommand();
50 comd.CommandText = queryLastSls;
51
52 DataTable slTable = new DataTable();
53 OleDbDataAdapter adapt = new OleDbDataAdapter(comd);
54 adapt.Fill(slTable);
55
56
57 ArrayList DataSalesArr = new ArrayList();
58 foreach(DataRow row in slTable.Rows)
59 {
60 CSDatasales sls = new CSDatasales();
61 sls.sz_province = row["WpszState"].ToString();
62 sls.sz_supervisorname = row["szName"].ToString();
63 sls.sz_salemanname = row["Expr1"].ToString();
64 sls.sz_salesmancode = row["szEmployeeId"].ToString();
65 sls.sz_Divisi = row["Divisi"].ToString();
66 sls.sz_typeOp = row["szDescription"].ToString();
67
68 DataSalesArr.Add(sls);
69 }
70 Tex.CloseConnection();
71 //AddQstrWhere("",wheretext);
72
73 return (DataSalesArr);
74
75 }
76 catch(Exception ex)
77 {
78 throw ex;
79 }
80
81 }
82 You see I want to make the query more dynamic. So instead of making the SQL parameter permanent I wanna make it dynamic, so the usercan choose whether they want to use the parameter or not. I already declare the parameter which is szSalesmanID. There's a function called AddQStrWhere which can make the query more dynamic. But the thing is when I wanna use the parameter it seems the code doesn't take it, it just use the regular query I dont know why.I already use the function but it just wont work, can you guys tell me what's wrong, Please I really do need some help from you guys, feelin; a lil' bit desperate in here.I appreciate any kinds of help, thanks. FYI: I use Visual Studio.NET 2003, SQL Server 2000.Best Regards.   

View 2 Replies View Related

Implementing SCD Type 1 && 2 Using DTS

Jul 22, 2003

Hi!

How to Implement scd type 1 and 2 functionality using DTS.
Implemented the functionality using T-SQLS, but want to make use of DTS. Can we do this using DTS without using T-SQLs.

Thanks

View 5 Replies View Related

Implementing Preconditions

Oct 23, 2006

I have about a half-dozen insertion tasks that depend on a condition: SQLServerProcessDate == OLEDBprocessDate. If the task executes early, old data gets inserted and needs to be backed out later on. (This happens about two-three times a month.)

The jobs start at 8:00 PM, but on occasion processing runs late. In order to make the task intelligent enough to not insert old data, I've thought of a couple options:

1.) Separate scheduled job runs continuously, comparing process dates. When the dates match, it sends a message to the other jobs. Pro: less repetitive. Con: another scheduled job?!? I'll have to learn the message queue task; a little bit complex; flood of database activity on message reception may slow system down

2.) Compare the dates in each individual task; if they're not the same, sleep for a while (15 min.) Pro: simpler. Con: I haven't found any way to pause/sleep/wait a task based on a condition; repetitive functionality in multiple tasks

Any opinions on which is the better choice?

View 7 Replies View Related

Implementing IDTSLogging

Oct 12, 2006

I am writing my own SSIS package host and I want to create custom logging and event trapping in the host. My goal is to reroute logging calls to the patterns and practices logging block and control the logging destinations using the config file.

Here is an excerpt of code from my main method of the host:

// recurse through all DtsContainers in package
//and enable logging, set filter kind to Exclusive, and clear filter list
ConfigureLogging(package);

// LoggingEventHandler inherits from Microsoft.SqlServer.Dts.Runtime.DefaultEvents
LoggingEventHandler eventHandler = new LoggingEventHandler();

// LoggingBlockLogger implements IDTSLogging
LoggingBlockLogger logger = new LoggingBlockLogger();
DTSResult result = package.Execute(null, null, eventHandler, logger, null);

The behavior I am looking for is that regardless of what logging providers are configured in the package, all the providers will be bypassed and all logging will be passed through my custom LoggingBlockLogger class.  However, I find that if there were any providers configured in the package, they are being passed logging events.  I tried returning 'false' from LoggingBlockLogger.Enabled, and I'm returning an empty array from LoggingBlockLogger.GetFilterStatus().

I followed the stack trace from the point of entry into the package log providers and found that they were being called directly from ManagedWrapper.Log.  Why are the package providers still being called?  What is the purpose of the IDTSLogging interface if every container simply passes log entries to the providers in its LoggingOptions.SelectedProviders collection?

Thanks!!!

View 2 Replies View Related

Implementing An Audit Mechanism

Jun 19, 2006

We're trying to implement an audit mechanism to track all changes made to our database and would appreciate any suggestions or alternate ways to do this, we're using the regular trigger based approach.
We also need to capture the user name of the  current logged in user - this is NOT the sql server database user, it is at the application level, the user who logs into our site. We were planning to pass this username using context_info in SQL SERVER through triggers as described here - http://www.sqlservercentral.com/columnists/spustovit/easyauditingasharedaccount.asp
Alternatively I could add a userId field to every BC and store the logged in user's name there but I'd rather avoid that. 

View 2 Replies View Related

Implementing A Customer System

Mar 4, 2006

Hi there, I am a little confused with some data ideas in .NET 2.0.
First, I now understand there are profiles for storing per-user information (such as address, etc). Now, each of my users will have say an inventory of equipment, that they can edit, add, etc. However I am not sure if using just regular tables would be better. Any suggestions?
Also, I understand using the profiles does not let you use things such as the DetailsView control, which would allow for automatic editing, adding, deletion, etc. This would be very nice to have, rather than implementing it myself.
If this is the case, how do I associate the new database with the ASPNETDB database? For example I will have a table in my new database that has columns [UserId, EquipmentName, Quantity, Description]. Now how do I get the logged in user's user ID to display only their equipment in a GridView say?
Thank you very much!
Tristan

View 3 Replies View Related

Implementing Standby SQL Server

Feb 15, 2000

Can I implement the Standby SQL Server using the SQL Server Standard Edition? What's actually the difference between Standard and Enterprise Edition? As I know the Enterprise edition can be installed for up to 32 CPU while Standard edition can only be installed for up to 4 CPU.

Many Thanks in advance!

View 1 Replies View Related

Help Implementing Service Broker

Feb 26, 2008



I am working on a project where I want to implement service broker. A lot of the examples that I have seen are all based on T-SQL. Here are my questions.

1. I have a web page that allows a user to type in an order. How do I put a message on the queue using a .NET assembly? Is there some sort of API set? Do I just pass the message to a stored procedure that puts the message on a queue?

2. Are there any samples that illustrate how to read messages off a queue using a console application or windows service? Is it possible to read the messages off of the queue with a console application or do you have to subscribe to the queue activation event and write a service program that runs under the control of service broker? All of the data that I need to fill the order has to come from a DB2 database on the mainframe. Therefore, I am stuck with creating an external application that processes the messages.

3. In order to use Service Broker, do I have to install Notification Services as well?

View 3 Replies View Related

Implementing Ranking Position

Jan 17, 2007

Hello,

I have a group that is custom made on the table's grouping expression, something like

=SWITCH(Fields!Country.Value="Portugal",IIF(Fields!Storetype.Value="Frs","Portugal Frs", "Portugal"),

Fields!Country.Value="Italy","Italy",Fields!Country.Value="Spain","Spain",Fields!Country.Value="United States","United States",

Fields!Country.Value="Internet","Internet",Fields!Country.Value<>"","Other")

The thing is that i order this by my value, and then i use a column that is the rowcount, but sadly i got

11 Portugal

19 United States

30 Spain

How can i do this like

1 Portugal

2 US

3 Spain

Is there something like in C ++1 or something that increments a number depending on the line of the table that is in?

Thank you

View 1 Replies View Related

Implementing Incremental Database Backup

Apr 11, 2007

Hi,

I am working on one application, which retrieves data from multiple tables in the database and all the fields retrieved, are exported as an excel sheet. All the export functionality is done through DTS. And the data is retrieved using an SP.

I am supposed to use an "incremental backup" approach here. Means, for the 1st scheduling of the package, all the database dump will be there in excel file. But, after that only fields that are updated/inserted are to be filled in the excel file. Each time, when the dump of the database is taken, the excel file is stored in an archive folder with Date and tiemstamp(e.g. TEST_11_04_2007_15_00_00.xls)

e.g. For the first dump, I get 100 records from the database. Before next execution of the package, 10 rows get inserted and 1 row gets updated. So, on the second time execution of the package, I should populate the excel sheet with those 11 rows only, and not 110 records.

I am not authorised to change the database schema.
So, is there any approach to try out this?

View 1 Replies View Related

Implementing DB Security In Existing Server

Mar 25, 2008

Dear Colleagues,

How do I install a Microsoft SQL Server 2005 database application in an existing server in an existing database server and still have the control over it and also restrict the new server Admin user from editing or even opening my DB. Any modification of my database or code should be implemented only by me. Is it possible to remove the Builtin Admin from the server role?? As in my case, there is no need for anyone else to open the DB in Management Studio at all as my VB application does all that is required.

Thanks and best regards,

Peter

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved