I saw your queston and answer.
Just come for a suggestion on the search path.
If you can use a stored procedure instead of
the sql statement in your front end code, that will
benefit system performance and protect your logic.
Here is a quick practice for show, I used pubs..authors
table becasue there is name column in it.
use pubs
go
drop procedure FindName_sp
go
create procedure FindName_sp
( @Name varchar(50)
, @match smallint
)
AS
if @match = 0 /** exact condition **/
Begin
select * from authors
where au_fname = @Name
end
if @match = 1 /** Wildcard condiction **/
Begin
select * from authors
where au_fname like '%' + @Name + '%'
end
return(0)
exec FindName_sp 'John', 0 -- no reuslt
exec FindName_sp 'John', 1 -- one row return