nbk5533


I would like to know if someone would know how to write a Stored Procedure (using Select statement) to search on a partial word, for instance, like "micro", for Microsoft Office, Microsoft Communicator, etc. or an ordered number of characters, that are unique, like "obe", and will retrieve, ad"obe" or adobe.

I'm using SQL 2005 and I'm running the search against a DB called platform_validation_tool and the table's name is dbo.software.

The important column names that I want to retrieve this data on are Name(which would be the simple name like Microsoft Office Communicator) and software_package(which would be a Tivoli package name from the registry stored in this column with the name like "Microsoft_Office_Communicator_2005_XP2K_I8^1.0.0.0.5).

I know you can use the clause WHERE NAME LIKE '%microsoft%' would retrieve all microsoft software packages. I'll assume you would have to setup parameters and concatenate them or something like that.

Has or would anyone know how to accomplish this task

Sincerely,

Wallace




Re: SP to search on any number of characters

Konstantin Kosinsky


What do you mean by "or an ordered number of characters, that are unique, like "obe", and will retrieve, ad"obe" or adobe." It's standart like operation.





Re: SP to search on any number of characters

Chris Howarth

You can concatenate search terms and wildcards for use with LIKE.

For instance the example text you gave matches the following pattern:

WHERE NAME LIKE '%microsoft%2005%0.5%'

You could easily produce such a string in application code and then pass the string to a parameterised stored proc:

DECLARE @searchstring VARCHAR(100)

SET @searchstring = '%microsoft%2005%0.5%'

SELECT...

FROM...

WHERE NAME LIKE @searchstring

The wildcards that can be used with LIKE are documented here:

http://msdn2.microsoft.com/en-us/library/ms179859.aspx

Chris






Re: SP to search on any number of characters

nbk5533

Thank you gentleman for your assistance. I now have a number of options from with which to choose.

I discovered (after days of research & testing) another method that would allow me to pull only the data I needed. I had to use a JOIN Clause in my SP and it pulls only the data I type into a textbox control.

Wallace