[thelist] SQL Server: How Can I Convert VARCHAR to INT?

Joshua Olson joshua at alphashop.net
Thu Aug 16 14:57:52 CDT 2001


Does something like this Work:

SELECT
  x =
  CASE
     WHEN IsNumeric(x) = '1' THEN Cast(x)
     ELSE NULL
   END
FROM mytable

This solution depends on the actual existance of an "IsNumeric" function and
a "Cast" function, as well as the database supporting the CASE-WHEN logic.

Did you actually want to update the table or just make a select that
returned what you wanted?

HTH,

-joshua





More information about the thelist mailing list