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 |
|
CanadaDBA
583 Posts |
Posted - 2004-10-26 : 08:53:18
|
| My developers had a trouble using ISNumeric(). ISNumeric('$500') returns TRUE while they want to return FALSE. BOL says ISNumeric()returns true for all kind of numerics and money. I can write a function to check if there are only numbers and period. Is there a better solution?Canada DBA |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-10-26 : 09:02:00
|
| SELECT CASE WHEN '$500' LIKE '%[^0-9.]%' THEN 'Not Numeric' ELSE 'Is Numeric' END |
 |
|
|
CanadaDBA
583 Posts |
Posted - 2004-10-26 : 09:36:02
|
It's interesting! Thank you. But I couldn't undrestand how LIKE '%[^0-9.]%' works.What's the trick behind that?quote: Originally posted by robvolk SELECT CASE WHEN '$500' LIKE '%[^0-9.]%' THEN 'Not Numeric' ELSE 'Is Numeric' END
Canada DBA |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-10-26 : 09:46:39
|
| ^ means not[] means a character0-9. means a character in range 0-9 or .% means anything solike '%[^0-9.]%'means the string contains a character that isn't in the range 0-9 or a .isnumeric will also return true for 1e2==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|