Think not of what to do to the row... think of what to do to the column... and, you don't have to do it all at once... Divide'n'Conquer. 😉
--===== Create and populate a test table. This is NOT part of the solution
DECLARE @PhoneNumbers TABLE (Original VARCHAR(30))
INSERT INTO @PhoneNumbers (Original)
SELECT '+44 (0) 1908 123 456' UNION ALL
SELECT '+44 (0) 121 430 4992'
SELECT Original,
REPLACE(STUFF(PartialFormat,CHARINDEX(' ',PartialFormat),0,')'),'(',' (') AS Reformatted
FROM (--==== Partially reformat the phone number by replacing the (0) and surrounding spaces
-- with just a left parentheses...
SELECT Original, REPLACE(Original, ' (0) ','(') AS PartialFormat FROM @PhoneNumbers
) d
Yields...
[font="Courier New"]Original Reformatted
-------------------- ------------------
+44 (0) 1908 123 456 +44 (1908) 123 456
+44 (0) 121 430 4992 +44 (121) 430 4992[/font]
--Jeff Moden
Change is inevitable... Change for the better is not.