T-SQL IsNumeric() and Linq-to-SQL

Posted by cdonner on Stack Overflow See other posts from Stack Overflow or by cdonner
Published on 2010-02-24T21:14:30Z Indexed on 2010/06/09 23:52 UTC
Read the original article Hit count: 518

Filed under:
|
|
|

I need to find the highest value from the database that satisfies a certain formatting convention. Specifically, I would like to fund the highest value that looks like

EU999999 ('9' being any digit)

select max(col) will return something like 'EUZ...' for instance that I want to exclude. The following query does the trick, but I can't produce this via Linq-to-SQL. There seems to be no translation for the isnumeric() function in SQL Server.

select max(col) from table where col like 'EU%' 
    and 1=isnumeric(replace(col, 'EU', ''))

Writing a database function, stored procedure, or anything else of that nature is far down the list of my preferred solutions, because this table is central to my app and I cannot easily replace the table object with something else.

What's the next-best solution?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about linq-to-sql