Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL equivalent to VAL not working
Message
 
To
14/08/2006 09:33:49
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:
01145292
Views:
28
This message has been marked as a message which has helped to the initial question of the thread.
Tracy,
This works fine for me. Try it in QA
DECLARE @Test TABLE (Number varchar(200))
INSERT INTO @Test VALUES ('301-1')
INSERT INTO @Test VALUES ('302-B')
INSERT INTO @Test VALUES ('303A')
INSERT INTO @Test VALUES ('304AZ')
INSERT INTO @Test VALUES ('305-AB')
INSERT INTO @Test VALUES ('306-Z')
SELECT CAST(LEFT(Number, PATINDEX('%[-A-Z]%', Number + 'A')-1) AS int), Number FROM @Test
      WHERE CAST(LEFT(Number, PATINDEX('%[-A-Z]%', Number + 'A')-1) AS int) BETWEEN 302 AND 305
>As I posted to Chad, I don't know what I was thinking Sergey! I'll fool around with it some and see what I can get working. I think the headache I am suffering from this am is inhibiting my thinking abilities! (That or my age :o) The latest test:
>
>SELECT CAST(LEFT(number, PATINDEX('%[-A-Z]%', number + 'A')-1) AS int) FROM occ_main
>
>bombs with:
>
>Conversion failed when converting the varchar value (20,22,24) to data type int.
>
>It pulls 2054 records and then bombs.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform