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

Chris Garrett chris at chrisg.com
Thu Aug 16 11:09:30 CDT 2001


cast(value as type) ?

--

                 Me: http://chrisg.com
  ASP/.NET Articles: http://www.realworldasp.net/
ASP/.NET Newsletter: http://www.aspalliance.com/chrisg/subscribe.asp
----- Original Message -----
From: "James Aylard" <webmaster at equilon-mrc.com>
To: "Evolt" <thelist at lists.evolt.org>
Sent: Thursday, August 16, 2001 5:03 PM
Subject: [thelist] SQL Server: How Can I Convert VARCHAR to INT?


> SQL Gurus:
>
>     I've got a MS SQL Server 7 database table with some columns that
contain
> varchar data. The intended use of these particular fields is to contain
> numeric data (and most of them do contain numeric data or are null), so we
> want to switch the data type from varchar to int. But some of them contain
> non-numeric data (which is unneeded and can be discarded), which prevents
a
> simple switch of the data type.
>     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).
>     Any help would be appreciated. Thanks.
>
> James Aylard
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list