Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cast(varchar column As Integer) fails
Message
De
07/07/2005 09:22:28
 
 
À
07/07/2005 08:18:33
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01029872
Message ID:
01029904
Vues:
12
Fabio,

Molto grazie (is that correct?) - anyway, thank's a bunch.

Although I'm not sure I understand the logic of it - why just 'E'?
Is that really the only one that will convert to numeric?


>>I tried:
>>
>>
>>Select DamageNo,Cast(RequisitionNo AS Integer) As RequisitionNo From
>>(Select  DamageNo,
>>   Case ISNUMERIC(DamageNo)
>>      When 1 Then DamageNo
>>   Else Null
>>   End As RequisitionNo
>>from dbo.DamageInserts) T
>>
>>
>>The column DamageNo is of type varchar and contains values such as '1542A111','0455E204','104702'...
>>
>>Isnumeric filters out '1542A111' as not convertible, but leaves '0455E204' because it can can be converted to float, that is, a numeric.
>>
>>Which is all Isnumeric promises to determine.
>>
>>Since I've got a legacy table to convert, I need is something like
>>
>>
>>-- pseudo code
>>
>>Select DamageNo,
>>   Case Cast(DamageNo As Integer)
>>      When -- no error occurred return the integer
>>   Else    -- Return Null
>>   End As RequisitionNo
>>from dbo.DamageInserts
>>
>>
>>Help is deeply appreciated.
>
>
>Select  DamageNo,
>   CAST(Case WHEN ISNUMERIC(REPLACE(DamageNo,'E','_'))=1 Then DamageNo End AS INTEGER) As RequisitionNo
>from dbo.DamageInserts
>
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform