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.
| Author |
Topic |
|
proplink
Starting Member
4 Posts |
Posted - 2010-12-15 : 10:21:54
|
| Hi. Does anybody have a suggestion for the TSQL that i can put in a stored procedure to convert a number into a standard format?I will pass a variable from a user form (or select a variable from a table) and call it @mobileNumber that will be in the UK mobile phone format '07986 123456' and convert it into the International format which will be dropping the 0 and replacing it with 44 and for good measure remove the white space - i.e. '447986123456'.If the variable is comming from a form input the user may already enter their mobile in International format in which case the procedure will need to recognise this.Thanks |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2010-12-15 : 11:00:13
|
| [code]DECLARE @mobileNumber varchar(20)SET @mobileNumber = '07986 123456'--SET @mobileNumber = '+44 7986 123456'SET @mobileNumber = REPLACE(REPLACE(@mobileNumber, ' ', ''), '+', '')SELECT @mobileNumber = CASE WHEN LEFT(@mobileNumber, 1) = '0' THEN '44' + SUBSTRING(@mobileNumber, 2, 20) ELSE @mobileNumber END SELECT @mobileNumber[/code] |
 |
|
|
proplink
Starting Member
4 Posts |
Posted - 2010-12-15 : 12:16:39
|
Thanks very much |
 |
|
|
|
|
|