Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 add '+' sign in front

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-06-20 : 02:45:00
how can i add in '+' infront of the mobile number?

i have a list of mobile number that need to add '+' in the front.

some already has the '+' sign infront. just need to update those who dont have yet.

mobileNo
60812321312
60812321311
60812312333
+60812345345
+60823542357

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-06-20 : 02:59:08
[code]
update t
set mobile = '+' + mobile
from tbl t
where mobile not like '+%'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

vinu.vijayan
Posting Yak Master

227 Posts

Posted - 2012-06-20 : 06:38:26
quote:
Originally posted by khtan


update t
set mobile = '+' + mobile
from tbl t
where mobile not like '+%'



KH
[spoiler]Time is always against us[/spoiler]





Very Nice one Khtan.
I did it with a Substring Condition to check the '+'.

But yours is way more simple than that.

Its just one of those days/times when only the harder solution comes to your mind......too much work I guess.

N 28° 33' 11.93148"
E 77° 14' 33.66384"
Go to Top of Page
   

- Advertisement -