Please help me with the below query,please modfiy and let me know,I use ssms
I need to display only Phonenumber
. Below is the query I'm using as of now. I divide it using two columns because there might be cell number
and home phone
.
CONCAT(RIGHT(LEFT(HR_PN_1.PhoneNumberID, 4), 3), REPLACE(RIGHT(HR_PN_2.PhoneNumberID, 8), '-', '')) as 'PersonPhone',
CASE
WHEN HR_PN_2.PhoneNumberID is not null
THEN CONCAT(RIGHT(LEFT(HR_PN_2.PhoneNumberID, 4), 3), REPLACE(RIGHT(HR_PN_2.PhoneNumberID, 8), '-', ''))
END as 'PersonWorkPhone',
Example of data in the PhoneNumnberID
column, I have in my table HR_PN_1 and HR_PN_2
is as follows:
(123)456-7890TOMMY
(123)456-7890 DAD
(123)456-7890 ***
(123)456-7890 2300
(123)456-7890CELL#
(123)456-7890
I need these numbers to be displayed as only in phone number format (123)456-7890