Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 help with text search

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2005-08-08 : 12:45:32
Hi,

I'm creating my first search stored procedure that searches thru a couple different columns. I have posted what I have so far below.

Do I have to use the CAST function to use the LIKE '% operator? What is the best way to do this and to ensure its fast.

Thanks again for any help

mike123




CREATE PROCEDURE dbo.select_searchMedia
(
@searchString varchar(50)
)
AS SET NOCOUNT ON

SELECT * FROM tblMedia WHERE mediaTitle LIKE @searchString OR mediaDesc LIKE @searchString



GO

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-08-08 : 12:50:48
when you say "Text Search"... do you mean you are searching a column of TEXT datatype?

To use the wildcard just concatenate it onto your input variable.

For example:

SET @searchString  = '%' + @searchString + '%'


Also, check out these articles on the subject:

http://www.sqlteam.com/item.asp?ItemID=1876
http://www.sqlteam.com/item.asp?ItemID=5857

Nathan Skerl
Go to Top of Page
   

- Advertisement -