Find Jobs
Hire Freelancers

Postgres Stored Procedure to Clean Up Phone Numbers

$30-250 USD

Completed
Posted over 13 years ago

$30-250 USD

Paid on delivery
We need stored procedures and an example of how to update an entire table in SQL to do the following: 1) strip out all non-numeric characters from each phone number (i.e., remove all ( and ) and . and - characters plus anything else in there) 2) if the resulting number starts with a 1, remove the 1 A suggested SQL Server based procedure is as follows: ALTER FUNCTION [dbo].[RemoveChars](@Str varchar(1000)) RETURNS VARCHAR(1000) BEGIN declare @NewStr varchar(1000), @i int set @i = 1 set @NewStr = '' while @i <= len(@str) begin --grab digits or (| in regex) decimal if substring(@str,@i,1) like '%[0-9]%' begin set @NewStr = @NewStr + substring(@str,@i,1) end else begin set @NewStr = @NewStr end set @i = @i + 1 end RETURN Rtrim(Ltrim(@NewStr)) END The second one removes the leading 1 if the phone number begins with a 1 and then checks if the phone number is longer than 10 characters, in which case it trims it to 10: ALTER FUNCTION [dbo].[Remove1AndCut](@Str varchar(1000)) RETURNS VARCHAR(1000) BEGIN declare @NewStr varchar(1000) --,@i int --set @i = 1 set @NewStr = '' --while @i <= len(@str) --begin --grab digits or (| in regex) decimal if substring(@str,1,1) = '1' begin set @NewStr = @NewStr + substring(@str,2,len(@str)) end if len(@str)>10 begin set @NewStr = substring(@str,1,10) end else begin set @NewStr = @NewStr end --set @i = @i + 1 --end RETURN Rtrim(Ltrim(@NewStr)) END This should work on latest PostgreSQL
Project ID: 919143

About the project

6 proposals
Remote project
Active 13 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See pm please
$60 USD in 1 day
4.9 (14 reviews)
4.9
4.9
6 freelancers are bidding on average $129 USD for this job
User Avatar
Please Check My PM. I am interested in doing this project.
$250 USD in 3 days
4.9 (12 reviews)
5.6
5.6
User Avatar
Hi There, I have a ready solution for you. Would be happy to share the details as we move forward. Regards, Anurag
$100 USD in 1 day
5.0 (7 reviews)
4.2
4.2
User Avatar
Check your P.M. I'll do this, and I'll do it well.
$160 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
Can provide the best one and error free.
$55 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
I can provide the SQL script to strip out all non-numeric characters from each phone number and also to remove 1 if the phone number starts with 1.
$150 USD in 2 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
Platte City, United States
4.9
149
Payment method verified
Member since Jul 13, 2009

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.