Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting Char(12) to Numeric
Message
From
27/03/2011 15:39:48
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01505130
Message ID:
01505136
Views:
37
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform