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 |
|
oguzkaygun
Yak Posting Veteran
53 Posts |
Posted - 2009-11-26 : 08:28:48
|
| helloi have records like below100.01.001100.01.002100.01.003ambrella01ambrella10ambrella1ambrella2ambrella3i should get ambrella10 as result when i enter ambrella to textbox and click FindRecordButton. Secondly i should get 100.01.003 as result when i enter 100.01. to textbox.My select query give me ambrella1 instead of ambrella10. but i get 100.01.003. What should i do to get true record for result ?Thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-26 : 08:32:11
|
| What is the logic?Why is ambrella10 and not ambrella1?MadhivananFailing to plan is Planning to fail |
 |
|
|
oguzkaygun
Yak Posting Veteran
53 Posts |
Posted - 2009-11-26 : 09:39:22
|
quote: Originally posted by madhivanan What is the logic?Why is ambrella10 and not ambrella1?MadhivananFailing to plan is Planning to fail
i should get max number about ambrella. ambrella1 is smallest than ambrella10.Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-26 : 10:01:16
|
| select top 1 col from your_table where col like @col_value+'%' order by replace(col,@col_value,'')*1 descMadhivananFailing to plan is Planning to fail |
 |
|
|
oguzkaygun
Yak Posting Veteran
53 Posts |
Posted - 2009-11-26 : 12:42:01
|
| thank you for your reply.it works perfect.But i cant understand your code.Can you explain your code ? especially replace(kod,@kod,'')*1what does it do ?Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-27 : 01:23:04
|
quote: Originally posted by oguzkaygun thank you for your reply.it works perfect.But i cant understand your code.Can you explain your code ? especially replace(kod,@kod,'')*1what does it do ?Thanks
It removes the word from data and multiply the remianing part by 1 to make it as a numberMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|