tags:

views:

71

answers:

3
Create Proc CargarAnuncioPorBusqueda
    @searchString varchar(max)
AS 
select * from Anuncio where titulo Like '%'+ @searchString + '%'

Say the user writes: "pools", would this Stored Procedure return everything that has "pools" in the "titulo"?

Thank you. :)

+3  A: 

Yes. It would return "spools", "poolside", "pools", etc.

flayto
Great! All I needed to know. Thank you.
Sergio Tapia
+2  A: 

Yes that's the correct use of the like operator.

You can also do a logical Starts With like this:

like @searchterm + '%'

and Ends With like this:

like '%' + @searchterm
Joseph
Your startswith and endswith are backwards.
Joel Coehoorn
@Joel LOL, thanks! Edited
Joseph
A: 

It's not a very fast search though.

Jay
How is this a slow search? I'm new to SQL in general. ;)
Sergio Tapia
It's not sargable (that means it can't use indexes).
Joel Coehoorn
it will look at every row in the table, that means that as data increases it will get slower and slower
KM