Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL equivalent to VAL not working
Message
 
 
To
11/08/2006 16:19:54
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01144926
Message ID:
01144980
Views:
16
Hi Tracy,
Try
DECLARE @StreetNumber varchar(10)
SET @StreetNumber =  '3505A'
SELECT CAST(LEFT(@StreetNumber, PATINDEX('%[A-Z]%', @StreetNumber + 'A')-1) AS int)
>I need to pull a range of records based on the street number. The number field is character. The problem occurs when a letter was entered in the number field as well as in 300A, 3505B, etc. Both of the examples below return the error:
>
>Conversion failed when converting the varchar value '3505A ' to data type int.
>or:
>Error converting data type varchar to numeric.
>
>
>select * from omain where 1100 < number and 3000 > number
>select * from omain where cast((number) as decimal(10,0)) > 1000 and cast((number) as decimal(10,0)) < 3000
>
>
>Recommendations?
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform