Q: how to copy from one column to another but with different data in sql i have a table city and columns name , id and address.




name
id
address




Hamburg
05088
45478, AachenerStr 128 num. +49(xxx)xxxxxxx




My question is how can i select only numbers from column address and copy it to new column numbers?
like this:




name
id
address
numbers




Hamburg
05088
45478, AachenerStr 128 num. +49(xxx)xxxxxxx
+49(xxx)xxxxxxx




A: *

*If the Length of the Mobile Number is fixed and Always last in position you can use
Select RIGHT(address,15)


*Extract using the + Symbol.
declare @address varchar(1000) = '45478, AachenerStr 128 num. +49(xxx)xxxxxxx'
select substring(@address,CHARINDEX('+',@address),len(@address))

