SQL Server CE (3.5) doesn't appear to support the IsNumeric
function. What are some alternatives to achieve the same functionality? Specifically, how would you test whether a CAST
from a string to a DECIMAL
datatype will succeed in SQLCE without IsNumeric
?
views:
26answers:
1
A:
One possibility is to explicitly add an ISNUMERIC
column to the table, and set the value (in your code, using your own method or a built-in .NET method) whenever the row is added or updated.
Another possibility is to use a query like this:
SELECT * FROM tbl WHERE col LIKE '%[^0-9]%'
MusiGenesis
2010-08-30 20:23:51
Typically what `IsNumeric`, `IsDate` and their ilk are used for is for making sure a `CAST` will succeed, and providing a reasonable default if it doesn't. You'd need to support initial negative signs and decimals and potentially the 'e' notation, and with all those considerations the statement becomes huge. Sure, a big-fat-brute-force `case` statement would get the job done, but I'm hoping there's something more, uh, reasonable already built in.
mattmc3
2010-08-30 20:39:53