sql server - SQL Function to assign areacode to phone number -
is possible create function assigns phone areacode(+44) mobile number depending on value of country field.
you can steal list of country codes/country abbr here https://countrycode.org/ , assign country id's them using identity column.
create new table using data. looks like:
country | country_code | country_id
then, suspect, have table like:
| phone_number | country | country_id
make changes existing table add country_id, improve performance:
alter table existing_table add country_id int; update e set e. country id = n.country_id existing_table e join new_table n on e.country = n.country
you need sql put (not function):
select e.something, format(concat(n.country_code,' ', e.phone_number), '###-##-####') completephone existing_table e join new_table n on e.country_id = n.country_id
Comments
Post a Comment