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 |
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-07-14 : 07:44:34
|
| Iam using sqlserver2008, now I want to find a maximum value of the field of "mpr_no" but the field type varchar...So how to find the max?select max(mpr_no) from mprmst......?ThanksParamu @ PARANTHAMAN |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-07-14 : 07:55:57
|
| Just I got the answer..let it may useful to someone elseselect max(0+mpr_no) from mprmstParamu @ PARANTHAMAN |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-14 : 08:27:59
|
This will crash if you have "bad" data in column mpr_no.i.e. 0+'some1234bad data' gives you much fun  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-14 : 08:33:45
|
| select max(0+mpr_no) from mprmstwhere mpr_no not like '%[^0-9.]%'MadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-14 : 08:36:25
|
quote: Originally posted by madhivanan select max(0+mpr_no) from mprmstwhere mpr_no not like '%[^0-9.]%'MadhivananFailing to plan is Planning to fail
déjà vu  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-14 : 08:42:16
|
quote: Originally posted by webfred
quote: Originally posted by madhivanan select max(0+mpr_no) from mprmstwhere mpr_no not like '%[^0-9.]%'MadhivananFailing to plan is Planning to fail
déjà vu  No, you're never too old to Yak'n'Roll if you're too young to die.
MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|