title: Validate phone number using SQL
body: <p>I need to check if phone number is in below format or not</p>
  <pre><code>+1(111)111-1111
  (111)111-1111
  1111111111
  </code></pre>
  <p>I am using this logic but not getting what I want</p>
  <pre><code>DECLARE @Customers TABLE (PhoneNumber VARCHAR(20))
  INSERT @Customers
  VALUES
      ('+1(111)111-1111'),
      ('1111111111'),
      ('11(11)111111'),
      ('11abcd1111'),
      (')123(45678-9-0-'),
      ('(111)111-1111')
  
  SELECT PhoneNumber
  FROM @Customers
  WHERE PhoneNumber NOT LIKE '%[^0-9()-]%'
  --AND REPLACE(REPLACE(REPLACE(PhoneNumber, '(', ''), ')', ''), '-', '') LIKE '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  AND LEN(REPLACE(REPLACE(REPLACE(REPLACE(PhoneNumber, '(', ''), ')', ''), '-', ''),'+','')) = 10 -- Alternate test
  </code></pre>
  <p>The result I am getting</p>
  <pre><code>1111111111
  11(11)111111
  )123(45678-9-0-
  </code></pre>
  <p><strong>UPDATE</strong>:  +1(111)111-1111 should also be in the result list l but it is not. How can I add it?</p>