Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacing one field with the numeric equivalent of a fie
Message
 
À
26/03/2008 15:39:28
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01305881
Message ID:
01305936
Vues:
10
>>It means that Field1 has values that cannot be converted to numeric(20,0).
>
>I have some records that have an empty values on Field1. So, that might be the reason. So, in order to achieve a complete conversion, I would have to put "0" in those empty values. Then, I can replace them with "" after.
>
>Thanks

BTW why you need Numeric(20)?
Wouldn't BIGINT work for you?
THAT is 20 bytes for record! BigInt is only 8 bytes and it is 2^63?
But you know your data better :-)
DECLARE @Test TABLE (Fld1 varchar(200), fld2 numeric(10))
INSERT INTO @Test VALUES ('1',0)
INSERT INTO @Test VALUES ('1e1',0)
INSERT INTO @Test VALUES ('1d12',0)
INSERT INTO @Test VALUES ('',0)

UPDATE @Test SET Fld2 = CAST(Fld1 as int)
WHERE ISNUMERIC(Fld1+'0e1') = 1

SELECT * FROM @Test
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