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

Matthias Ritzkowski Matt at grndwtr.com
Thu Aug 16 12:20:57 CDT 2001


loop through every character in every record.
test for isnumeric()= true
if not replace the character with ""
then do a cint() on the string and put it into the new table ...

That should work!
Matthias

-----Original Message-----
From: James Aylard [mailto:webmaster at equilon-mrc.com]
Sent: Thursday, August 16, 2001 13:17
To: thelist at lists.evolt.org
Subject: Re: [thelist] SQL Server: How Can I Convert VARCHAR to INT?


Ryan,

> Yep, SQL is better...

    Hmm. This looks promising. One thing I now realize I made as clear as
mud in my original post was the part about discarding unneeded data. What I
meant (though I didn't clearly state) was that in those fields that contain
non-numeric data, I would still like to keep the numeric portion of the
data; I can discard the non-numeric portion. For instance, say I have the
value "250 PSIG" -- I want to keep the 250, but I can discard the " PSIG"
portion.
    Looks like a job for regular expressions which, afaik, SQL Server
doesn't support. Still thinking from within my little box, is there a
straightforward way to do that, as well?
    Thanks. (And thanks Rudy and Joshua for your feedback, as well.)

James


---------------------------------------
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