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.
| Author |
Topic |
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2007-10-25 : 14:13:32
|
| I am new to SQL ,trying to create a search procedure. I want it to work like this .Take in a parameter "param" then return result based on the match to the "param". So if I am giving "param"=New. It should give me results like New York City,New York ,New Jersey, New Hampshire etc. But If I am giving New York, It shouldn't return New Hampshire and New Jersey and must return new York and New York City.If I give "param"= New York City then only New York City should be returned. What is the best approach for doing this?Please help. |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-10-25 : 14:18:54
|
| Use LIKE.Select * from table where field LIKE @param |
 |
|
|
Zoroaster
Aged Yak Warrior
702 Posts |
Posted - 2007-10-25 : 14:52:26
|
If using LIKE the query will need 'value%' or something similar. In the stored procedure you will need to concatenate that to the @param value. Future guru in the making. |
 |
|
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2007-10-25 : 17:22:02
|
| Yep, you are right... |
 |
|
|
|
|
|