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

Anthony Baratta Anthony at Baratta.com
Thu Aug 16 11:28:26 CDT 2001


At 09:03 AM 8/16/2001, you wrote:
>SQL Gurus:
>
>     Is there a straightforward way to convert a varchar column to an int
>column, short of manually editing the offending data? CAST throws an error
>when it hits a field that contains non-numeric data or isn't null (which you
>already knew, I'm sure).

What Platform?

Create a New Column, INT Type, then you could write a Perl/PHP/VBS script 
to iterate through the rows discarding the Non-Integer data and place it in 
the new column. Rename the olde column, rename the new column.
---
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."





More information about the thelist mailing list