Microsoft
Software
Hardware
Network
Question : use the cast or convert function on a varchar field
I have a varchar column in my table that contains commodity codes. Most of these codes are numeric and I want to find all records that have a commodity code between 2 and 99. I have tried to use the following statment:
Select * from sca
where cast(sca_commcode as bigint) between 2 and 99
This produced an error that stated error converting data type varchar to bigint.
After viewing the records, I see that some of the commodity codes are text entries such as 'Engine'
Is there a way to use cast or convert (or someother function) to return a value of zero if the value is a text entry? I guess what I am looking for is functionality similar to the VB val function.
Answer : use the cast or convert function on a varchar field
please try this:
Select * from (
select * from sca where isnumeric(sca_commcode) = 1
) sq
where cast(sca_commcode as bigint) between 2 and 99
Random Solutions
"Previous session of OneNote still exiting"
VIEWING INTERNAL WEB SITES WITH FOREFRONT TMG CLIENT
Deletion of record - But HOW ? Very odd.
VBA - IF Condition and Fill Down, added to existing code
how can I compare two databases in foxpro to check if they are identical?
nVidia nForce Raid controller embedded in Proliant ML115 G5 Event 129
I want to hyperlink a image in pdf using vb.net code using iTextSharp.text and Imports iTextSharp.text.pdf class
Export table to another Access DB
Bad email locks up Outlook Express, can't move or delete
odbc problem (sqlexec, sqlconnect)