How To Implement Search Function

Feb 1, 2007

I have a table search the record. The user can search by name, id, status, address and other information.
I want to make the search function more robust. For example, when the database has a record with name = "Michael Jackson", either typing any subset of the name will show this record.
I would like to know if there is any easy way to implement this with VS2005 and SQL2005 Express.
Thank you 

View 3 Replies


ADVERTISEMENT

How To Implement This As A Function?

Jul 6, 2007

Hi all,

I've been using a piece of transact code to generate random strings of characters in a lot of scripts and I wanted to wrap it up all nice and neat into a function. I came up with the script below.

However, this fails with the following error..
quote:Invalid use of 'rand' within a function.
I've allready tried using dynamic sql and sp_executesql inside the function hoping that a new scope would let me use rand() but that isn't allowed either.

I'm Using sql server 2000. Any ideas?

Charlie.

-- snip ----

CREATE FUNCTION dbo.randstr (
@lengthINT)
RETURNS VARCHAR

AS BEGIN
DECLARE @outputVARCHAR(8000)
DECLARE @allowedVARCHAR(8000)

SET @allowed = '234679abcdefghjkmnpqrstuvwxyz234679ACDEFGHIJKLMNPQRTUVWXYZ'

SET NOCOUNT ON
DECLARE @charmapTABLE (charpos INT IDENTITY (1,1), symbol CHAR)
DECLARE @counterINT
DECLARE @characterINT
DECLARE @maplengthINT

SET @maplength = LEN(@allowed)
SET @character = 0
SET @output = ''

-- Insert the allowed characters into the character map table
SET @counter = 1
WHILE (@counter < @maplength + 1) BEGIN
INSERT INTO @charmap SELECT SUBSTRING(@allowed,@counter,1)
SET @counter = @counter + 1
END

-- Start the loop to generate @output
SET @counter = 1
WHILE (@counter < @length + 1) BEGIN

-- RAND() should output a floating point number between 0 and 1 however...
-- Sometimes the rand() function spits out a number greater than 1
-- or the multiplication results in 0
WHILE (@character < 1) OR (@character > @maplength) BEGIN
SET @character = CAST(@maplength * RAND()+1 AS INT)
END

-- Add the random character to @output
SET @output = @output + (SELECT symbol FROM @charmap WHERE charpos = @character)

-- Increment and Reset the @character variable
SET @counter = @counter + 1
SET @character = 0
END


RETURN @output
END

-- end snip ---

View 3 Replies View Related

How To Implement Site Search && Full Text Serch On SQL Server

Feb 28, 2008

Hi,
I want to implement site search in my application, I got the solution of searching the static content, but most of the pages in my application is content based(content is coming from database at runtime), so those content I am not able to search from database.
While searching about the same, I got information about Full Text search (FT) in SQL Server 2005, but whether it will work in SQL Server 2005 Express or not?
I didnt get exact steps to implement FT on my database so far....
Any help?
 

View 1 Replies View Related

How To Implement Alter Database Implement Restrictions On SQL2K ?

Dec 28, 2007

Hi Guyz

it is taken from SQL2K5 SP2 readme.txt. Anyone have idea what to do to implement this ?
Our sp2 is failing. we suspect the above problem and researching it.we are running on default instance of SQL2K5 on win2003 ent sp2

"When you apply SP2, Setup upgrades system databases. If you have implemented restrictions on the ALTER DATABASE syntax, this upgrade may fail. Restrictions to ALTER DATABASE may include the following:

Explicitly denying the ALTER DATABASE statement.


A data definition language (DDL) trigger on ALTER DATABASE that rolls back the transaction containing the ALTER DATABASE statement.


If you have restrictions on ALTER DATABASE, and Setup fails to upgrade system databases to SP2, you must disable these restrictions and then re-run Setup."

thanks in advance.

View 4 Replies View Related

Search Function

Apr 4, 2007

I am trying to write a used car search function I want the user to be able to select a MAKE from the 1st drop down list and a MODEL from the second drop down list and click a button and for the data to be shown in a gridview, the code below is what I have so far and works i.e when user selects a make it shows all cars for that make, but now how do I take it further and add the model on there so that when the user selects i.e BMW as make and Z3 for model it only shows all BMW Z3'S
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>">
</asp:SqlDataSource>
<br />
<asp:DropDownList ID="ddmake" runat="server" DataSourceID="SqlDataSource2" DataTextField="make"
DataValueField="make" AutoPostBack="True">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT [make] FROM [used]"></asp:SqlDataSource>
&nbsp;&nbsp;</div>
<asp:button id="button1" runat="server" text="search"/>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
&nbsp;
</form>
</body>
</html>
 
Here is the code behind the page
Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
SqlDataSource1.SelectCommand = "select * from [used] where make like '%" & ddmake.Text & "%'"
SqlDataSource1.DataBind()
End Sub

View 26 Replies View Related

Search Function

Nov 28, 2007

We are in the process of developing an onlinestore like www.componentsource.com.We need to search for a product within our website.We already created pages using html.I have to take the 1st para of the product description and display. I don't want to save the description in the table how to do it? 

View 1 Replies View Related

Search Function

Nov 6, 2007

Hi all I have a search function in one of my database's that when you click on the command button it window comes up that ask you for the last name. What I would like to do is alter it so that users can type in SM and get all the names that start with SM or Ma?? Like a Starts with. How can I do that
= N'[@Enter_LastName].[dbo.Revocatiions] ALike [ta%]'


CREATE FUNCTION dbo.Revocations
(@Enter_LastName nvarchar(50))
RETURNS TABLE
AS
RETURN ( SELECT [SSN], [TM#], FirstName, LastName, ReasonofRevocation, Notes, [I/R #], Date
FROM dbo.Revocations_Tbl
WHERE (LastName = @Enter_LastName))

View 14 Replies View Related

Search Function

Nov 7, 2006

Hi All,

Here's my problem:

I create titles and submit them for approval. Once approved I can edit them again and either save them or submit them for approval again.

My problem is:
When I am creating a title and saving it in the drafts and searching for the title, I am able to find it in the result page. This is before approval.
When I submit the same title for approval and it's approved and then I change the title and save it as draft and then search the new title I cant find it. But when I search with the old title it shows me the result but with the new title name.

When I check the db and search for the new title no records found.
When I check the db and search for the old title the system returns me the record with the same old name.

So when I search the old title in the db it returns the old title.
So when I search the application for the new title it returns the old title.

Help Appreciated!

Using SQL Server 2005

View 11 Replies View Related

Extend Search Function

Mar 6, 2007

HelloIn my website I have a textbox to search some products, but it would like to extend my search-function so that it could find special characters. For example:When I search Mexico, I would like to find México. Is there an easy way to do this?Thanks in AdvanceWesley

View 1 Replies View Related

Help Me Write A Search Function Please

Jun 8, 2007

Hi all,I'm very new to ASP.NET stuffs, I'm trying to write a Search function for my website... I have two text boxes, one if called "SongTitle" and the other is "Artist"... Now I need to populate the GridView to display the result, based on the input of the textbox... So if only the "SongTitle" have input, it will search for the Song Titles on the database... if the Artist is searched, then it will return the artist... If both text boxes have value in them, then it need to check for both fields in the database and return the correct item... For the "Artist", I have 2 columns in the Database (originalArtist and performer), so for the Artist select statement, it need to check both columns on the table, if any of them match then it will return the item. Any help would be greatly appreciated,Thank you all,Kenny. 

View 15 Replies View Related

Search Function Problem

Sep 10, 2007

Hi, I am using the following sql for search function:
Select * From TableABC Where condition LIKE '%xyz%'
However, it does not provide good results, some results is not accurate, I would like to ask, is it any better mechanism for searching?
Please advise. Thanks~
James

View 2 Replies View Related

How To Search Using PATINDEX Function...Plz Help

Feb 11, 2007

Hi,

How to search the last occurance of one String in to another string..Using function PATINDEX() in a column of data type Text..

plz Give some solution i really need it ...



Thanks Yogesh

View 7 Replies View Related

SQL Search String Function

Jun 2, 2008

The 'LIKE' function looks for words that start with whatever is in the like condition. Is there an sql function similar but will look and compare at any part of the search string.

For example I am using a webservice in dot net to populate a dropdown list using this sql

SELECT compound_name FROM dbo.compound_name WHERE compound_name like @prefixText

In this table there is a compound called SILCAP310 and I would like the search function to pick up 310 if I put this into the @prefix parameter. (but I would still like the search to perform like the 'LIKE' does also.

SELECT compound_name FROM dbo.compound_name WHERE compound_name like @prefixText or compound_name SearchPartString @prefixText

Thanks in advance

View 4 Replies View Related

Function To Search For Characters

May 5, 2008

Hi All

Is there a function to search for characters in the string simlilar to the IndexOf function is C#.net?

I need answers urgently.

View 3 Replies View Related

How Can I Search All My Sprocs To See If Any Use A Function?

May 6, 2008

Anyone have the code that would allow me to see if any of my sprocs contain references to a function? I imagine it would someting like select name from sysobjecst where charindex(whatevertextis, 'ufnName') > 0

Thanks

View 5 Replies View Related

URGENT!!! Search Function Database Problem!

Jan 23, 2008

Hi all,
I have a search function in my website, which is fully functionable.
But currently, this is the issue that I am having problem with.
For example:
I have only the name 'John' in my database.
When the user search for 'John Tan', no results is shown as there was no such name in the database
But if this happens, I want 'John' to be always returned and shown, no matter what 'John' the user search - E.g "john tan", John Loh", john wee"
So, how do I go about doing this? I have done some research on how to go about doing it, what I found useful was the .Replace() function. However, I can never predict in advance what user is going to key in.
Any help is welcome as this is a rather pressing problem of mine. Thanks for all the help in advance!!!

View 21 Replies View Related

URGENT!!! Search Tool Function: Splitting A String

Jan 14, 2008

Hi All!!!
I was tasked to come up with a search function and the content of the database given to me is in Chinese Characters. This would be my first time dealing with Chinese characters in the database and I need help with the following problem:
The company wants to conduct the search in such a way that, instead of having the system read the entire sentence/phrase which the user keyed in as a SINGLE string, they want the Chinese Characters to be accessed individually, so that as long as any information in the database contains any one of the characters which the user have entered, they will be retrieved and returned.
So how do I go about doing this? Does it have anything to do with Unicode? By the way, everything abt the search tool is working fine, I am just left with this dilemma of having the system recognise the entire sentence as ONE STRING, instead of conducting a search word by word or character by character.
Anyway, the following is the SQL statement of my SQL Data Source which is bound to a Gridview displaying the returned results after a search is done...1 SELECT Name, Trans, Address1, Address1T, Address2, Address2T, City, CityT, CRPLID
2 FROM CRPL
3 WHERE (Trans LIKE '%' + @Trans + '%') OR
4 (Name LIKE '%' + @Name + '%') OR
5 (Address1 LIKE '%' + @Address1 + '%') OR
6 (Address1T LIKE '%' + @Address1T + '%') OR
7 (Address2 LIKE '%' + @Address2 + '%') OR
8 (Address2T LIKE '%' + @Address2T + '%') OR
9 (City LIKE '%' + @City + '%') OR
10 (CityT LIKE '%' + @CityT + '%')

 
Thanks for all your help in advance!!!

View 6 Replies View Related

Built In Function To Search The Occurence Of Char In String

Jan 10, 2008



Hi Everyone-
i woder if someone know Built in function to search the occurence of char in string in T-SQL

and iam not talking about the Index of the first occurence (e.g CHARINDEX )
but it is more generic

i want to send to the function to ask about the index the second or the third or N occurence of the char.
and i wonder if it is built in for performance reasons

example
getseachIndex("M|d|d","|",2)==> the result is 4

View 3 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

How To Implement?

Apr 12, 2005

Hi all,
I had many groups of data which column A store number & column B store location. My syntax as below :-
select count(columnA) as no, columnB from table group by columnB
No    columnB
20     A
10     B
5       C
How can I select 5 rows for Each ColumnB? (total 15 rows of record)
Thanks!

View 3 Replies View Related

How To Implement Cursors In Sql

Feb 29, 2008

 hi friends.......         I have one doubt.                  how can we use cursor in sql. in oracle they implement cursors on stored procedure,                   can we implement same concept in sql stored procedure...regards Samuel chandradoss . J 

View 3 Replies View Related

Cannot Implement Mirroring

Apr 1, 2008

Hi,

I have place an question, but in some other place in the same forum.

My apologies for that



I wanted to implement mirroring
I hereby let u know the steps



1. Created a database in Principal server named Mirror1 and one table named tblMirror1.( no values inside the table)

2. Repeated the same in Mirror in Witness

3. Selected the Principal server's database -->right click-->tasks-->mirror

4. from the left hand panel selected Options -->recovery model-->full

5. selected Mirroring from left hand panel-->configure secuirty-->entered mirror and witness name--Success



6. When I click on start mirroring I have an error stating

" Alter failed for database mirror1"

"Database mirroring cannot be enabled because Mirror1 database may have bulk logged changes that have not been backed up etc...."




7. followed this one
BACKUP database mirror1 TO DISK='C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupmirror1_FULL.BAK'

got the answer as

Processed 160 pages for database 'mirror1', file 'Mirror1' on file 2.
Processed 1 pages for database 'mirror1', file 'Mirror1_log' on file 2.
BACKUP DATABASE successfully processed 161 pages in 0.318 seconds (4.147 MB/sec).

According to sources
Run a restore of this backup on your mirror.
This can be done through the GUI or using a T-SQL command.

The database restore must use the NO RECOVERY option, so the database stays in a loading state.

Also the database name on the mirror must be the exact same name as the principal

RESTORE TestMirror FROM DISK='C:Backup TestMirror_FULL.BAK' WITH NORECOVERY



Hence did the below


RESTORE database mirror1 FROM DISK='C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupmirror1_FULL.BAK' WITH NORECOVERY

ERROR

Msg 3201, Level 16, State 2, Line 1
Cannot open backup device 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupmirror1_FULL.BAK'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.


HENCE MODIFIED AS

use master
go
RESTORE database mirror1 FROM DISK='C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupmirror1_FULL.BAK' WITH NORECOVERY

Msg 3201, Level 16, State 2, Line 1
Cannot open backup device 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupmirror1_FULL.BAK'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.



Please let me know what shuld i modify

regards
cmrhema

View 20 Replies View Related

Implement One Is To Zero Or Many Relationship

Sep 19, 2013

Just wondering if there was a way to implement a one is to zero or many relationship with sql or can you only have a one is to one or many?

View 2 Replies View Related

How To Implement Replication

Mar 26, 2008

Want to implement replication in sql server 2005

Kindly let me know how to do it.
Please


regards
cmrhema

View 2 Replies View Related

How To Implement This Scenario

May 11, 2006

Hi,

i hav a text file in this format..
currency,exchangerate(INR),date
dollar,45,20/04/2006
dollar,46,22/04/2006
britishpound,65,20/04/06
dirham,12,20/04/06..etc..

now,i want that using this as source.. 2 tables should be created and filled with appropriate data..
CurrencyMaster..Currencyid(PK),Currencyname
CurrencyDailyRate..ID,Currencyid(FK),rate,date

how can i do it using SSIS?
thks

View 1 Replies View Related

How To Implement This In SSIS

May 22, 2006

Greetings SQL friends!

I have the following transact SQL code which I want to change to a set of SSIS components.



SELECT blah, blah

FROM PSTAGE..[stage_OFFER_PRICE_DIVIDEND] AS SOPD
LEFT OUTER JOIN PSTAGE..[stage_PRICE_GRP] AS SPG
ON SOPD.PRICE_GRP_ID = SPG.PRICE_GRP_ID
LEFT OUTER JOIN PSTAGE..[stage_type] AS TYP
ON TYP.TYPE_CD=SPG.PRICE_TYPE_TYPE4_CD
and TYP.TYPE_CL_CD = '0017'



I know I can join two data sets using a merge join (left join) but how do I combine a third merge join? Should I be doing this or should I just stick my code in a SQL Task instead?



Your help would be appreciated.

View 1 Replies View Related

How Do I Implement If Then Else Conditions

May 28, 2007

Hi All,



I'm very new to Integration Services. Self Learned this ETL tool based on my prior ETL tool knowledge.



Can you tell me how do write IF Then Else conditions for every column in my source and redirect to a single output?





Hey correction here ... i'm using flat file as my source





Thanks in Advance,

Suresh N

View 7 Replies View Related

How To Implement Paging

Oct 27, 2006

My report is taking long time to display hundered of records.So we want to display 15 records per page and Next page link at the end of report.Please help me how to do this.

View 7 Replies View Related

Help W/ Stored Procedure? - Full-text Search: Search Query Of Normalized Data

Mar 29, 2008

 Hi -  I'm short of SQL experience and hacking my way through creating a simple search feature for a personal project. I would be very grateful if anyone could help me out with writing a stored procedure. Problem: I have two tables with three columns indexed for full-text search. So far I have been able to successfully execute the following query returning matching row ids:  dbo.Search_Articles        @searchText varchar(150)        AS    SELECT ArticleID     FROM articles    WHERE CONTAINS(Description, @searchText) OR CONTAINS(Title, @searchText)    UNION    SELECT ArticleID     FROM article_pages    WHERE CONTAINS(Text, @searchText);        RETURN This returns the ArticleID for any articles or article_pages records where there is a text match. I ultimately need the stored procedure to return all columns from the articles table for matches and not just the StoryID. Seems like maybe I should try using some kind of JOIN on the result of the UNION above and the articles table? But I have so far been unable to figure out how to do this as I can't seem to declare a name for the result table of the UNION above. Perhaps there is another more eloquent solution? Thanks! Peter 

View 3 Replies View Related

SQL Search :: Full Text Search With Single Character Returns All Rows

Jul 21, 2015

Our clients want to be able to do full text search with a single letter. (Is the name Newton, Nathan, Nick?, Is the ID N1, N2...). Doing a single character full text search on a table work 25 out of 26 times. The letter that doesn't work is 'n'. the WHERE clause CONTAINS(full_text_field, ' "n*" ') returns all rows, even rows that have no 'n' in them anywhere. Adding a second letter after the "n" works as expected.

Here is an example

create table TestFullTextSearch (
Id int not null,
AllText nvarchar(400)
)
create unique index test_tfts on TestFullTextSearch(Id);
create fulltext catalog ftcat_tfts;

[Code] ....

View 4 Replies View Related

SQL Server 2014 :: Semantic Search Not Finding Keywords Identified By Full-Text Search?

Nov 6, 2014

I have a scenario of where the standard Full-Text search identifies keywords but Semantic Search does not recognize them as keywords. I'm hoping to understand why Semantic Search might not recognize them. The context this is being used in medical terminology and the specific key words I noticed missing right off the bat were medications.

For instance, if I put the following string into a FT indexed table

'J9355 - Trastuzumab (Herceptin)'
AND
'J9355 - Trastuzumab emtansine'

The Semantic Search recognized 'Herceptin' and 'Emtansine' but not 'Trastuzumab'

Nor in

'J8999 - Everolimus (Afinitor)'

It did not recognize 'Afinitor' as a keyword.

In all cases the Base of Full-Text did find those keywords and were identifiable using the dmvsys.dm_fts_index_keywords_by_document.It does show the index as having completed.

why certain words might not be picked up while others would be? Could it be a language/dictionary issue? I am using English and accent insensitive settings?

View 0 Replies View Related

How To Implement A DropDownList W/o A Table

Jun 9, 2007

I am using Visual Studio 2005 & SQL Server. How do i implement a DDL for users to select which value to input. like i can with Access. i do not need a table i think. if not the table would have only ID & Value.?

View 2 Replies View Related







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