Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting Char(12) to Numeric
Message
De
27/03/2011 15:39:48
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01505130
Message ID:
01505136
Vues:
38
>Storing telephone as numeric is not recommended, however, you may want to try
>
>select tel, cast(F.NewTel as Numeric(15)) as NewTel from Site
>CROSS APPLY (select replace(Tel,'-','') as NewTel) F
>where ISNUMERIC(F.NewTel) = 1 
>
I got confused with samples I saw on the net where many are using Str() to extract a portion of a string. When I used Substring(), it worked:
UPDATE Site SET [Tel-Temporary]=CONVERT(Numeric,SUBSTRING(Tel,1,3)+SUBSTRING(Tel,5,3)+SUBSTRING(Tel,9,4))
We store that as numeric for indexing performance, search, etc, where the user simply enter the digits, which includes the regional code, and we have a framework specific telephone number search which will grab everything greater than what is being entered. This works extremely fast and avoids all the special non conventional ways of data entering each user will use.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform