Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL equivalent to VAL not working
Message
 
À
14/08/2006 09:33:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01144926
Message ID:
01145292
Vues:
30
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform