Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2004, 06:52 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default 7 Digit number

I have a customer table which contains phone numbers some have area codes and some do not. I want to be able to update [u]only</u>customer with 7 digits only (ex: 1234567) not the ones with area code (Ex:9991234567). how can I go about doing this?


update customer
set phone=("999"+ ','+'phone)
where phone ?

Any help will be greatly appreciated.

__________________
Jaime E. Maccou
 
Old April 2nd, 2004, 12:49 AM
Registered User
 
Join Date: Feb 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to xologist Send a message via Yahoo to xologist
Default

I am not certain what data type your telephone column is but SQL has this cool function called STUFF that might be useful to you in this situation because it will count characters in a string and do inserts and deletes. I can see a script that could be programmed that counts the string lenght to determine if it needed an update or didn't need an update. The ones needing an update would be parsed from the others then the proper digits would be stuffed into the field in their proper places. I hope this is of some help ?? Jim

 
Old April 3rd, 2004, 11:52 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

where len(phone)=7
 
Old April 4th, 2004, 01:02 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Quote:
quote:Originally posted by planoie
 where len(phone)=7
Thank you very much, right on time

My results

update customer
set phone='999'+phone
where len(phone)=7







Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation For Phone Number and Mobile Number dhruthi.ram99 Javascript How-To 12 October 30th, 2011 07:24 AM
Extract a digit from specified position sektor Visual Basic 2005 Basics 10 June 9th, 2008 05:05 PM
TAPI 3.0 : Problem in Digit Detection Qaisar Visual C++ 0 March 10th, 2006 09:54 PM
number? crmpicco Classic ASP Basics 2 June 10th, 2005 05:14 AM
How to keep two digit after float number? Edward King Javascript 1 July 30th, 2003 01:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.