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 |
|
jimoomba
Yak Posting Veteran
90 Posts |
Posted - 2011-11-09 : 01:55:39
|
| Hi All,Iam having a users table which contains "Mobile" column as well. I want a query to set the country code(+91) value by default into the column name so that the column should be updated with the mobile number along with the default country code. kindly help me on thisThanks,Ramrams |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-09 : 02:41:53
|
| do you have another column (or table) which stores the country code values?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jimoomba
Yak Posting Veteran
90 Posts |
Posted - 2011-11-09 : 02:48:45
|
| no visakh, i dont have have another column (or table) which stores the country code valuesrams |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-09 : 02:57:33
|
| then you need to get country codes for all required countries and then store it in a mapping table first with country names.you can then add a trigger to this addition each time upon insertion or updation of data based on country name stored in your column. Another way is to keep seperate column for phonenumber value and then create a computed column for phnowithcountrycode which appends countrycode value in the other table with entered phone number------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jimoomba
Yak Posting Veteran
90 Posts |
Posted - 2011-11-09 : 03:03:47
|
| Hi Visakh,As iam new to this field could you just help me in sending the query for that, so that it would be a great help for me as the requirement is very urgent.Thanks,Ramrams |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-09 : 03:36:56
|
quote: Originally posted by jimoomba Hi Visakh,As iam new to this field could you just help me in sending the query for that, so that it would be a great help for me as the requirement is very urgent.Thanks,Ramrams
search in google for country codes list and prepare a data list with country names against code. put them in an excel and create an insert script using them for mapping table. I dont have time currently to do that for you.then you can apply either of two approaches to get them prefixed to your mbile numbers.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jimoomba
Yak Posting Veteran
90 Posts |
Posted - 2011-11-09 : 03:41:18
|
| Thank you visakhrams |
 |
|
|
|
|
|