By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

wild characters in stored procedures with parameters?

P: 3
Hello everyone,

i wonder if someone can give me some idea how and what is the right way to use wild characters in stored procedures with parameters...
Assuming that
@searchs_text is the parameter...
this:

WHERE last_name LIKE '%' + @search_text + '%'

seems does NOT work..

any help in this matter will be greatly appreciated.

thank you!
Nov 29 '06 #1
Share this Question
Share on Google+
3 Replies


iburyak
Expert 100+
P: 1,017
What error do you get? It should work.
Nov 29 '06 #2

P: 82
hmm...
create your stored procedure like this:
create procedure searchaddrs @addrs varchar(20) = '%Av%'
as select name,city,address from profile where address like '%Av%'


you can always override the default value by giving the desired one in the exec procedure statement.
hope this will give the desired output.
Nov 30 '06 #3

iburyak
Expert 100+
P: 1,017
You hardcoded where condition and it probably searched the same all the time.

Change to this:


create procedure searchaddrs @addrs varchar(20) = '%Av%'
as select name,city,address from profile where address like '%' + @addrs + '%'
Dec 1 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.