June 21, 2011 at 11:12 am
Hi all,
How can I achieve the following:
-------------------------------------
If the phone number's first character is 1-9
{add a leading 0}
Else
{Do nothing to the phone number}
---------------------------------------
Thanks for your help.
June 21, 2011 at 11:22 am
SELECT CASE WHEN LEFT(PhoneNo, 1) LIKE [0-9] THEN '0' ELSE '' END + PhoneNo FROM dbo.Table WHERE...
June 21, 2011 at 11:27 am
UPDATE tbl SET phoneNumber = '0'+phoneNumber WHERE LEFT( phoneNumber, 1) LIKE '[1-9]'
... should work.
EDIT: Dang Ninjas... sneaking in unexpectedly EVERYWHERE!
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
June 21, 2011 at 11:47 am
Craig Farrell (6/21/2011)
UPDATE tbl SET phoneNumber = '0'+phoneNumber WHERE LEFT( phoneNumber, 1) LIKE '[1-9]'... should work.
EDIT: Dang Ninjas... sneaking in unexpectedly EVERYWHERE!
It's easy when you type more than 3 words / minute ;-)!
P.S. Now you figured out the suffix in my name!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply