title: Checking data type after a split operaton in sql server
body: <p>This is my question. I'm receiving a String with values that can be numberic or alphanumeric separated by commas:</p>
  <p>'1,2,3,4' or '1,2,b'</p>
  <p>My goal is to return another string with this conditions:</p>
  <p>Numerica values : Return the same string</p>
  <p>Alphanumeric values  : Return the values between single quotation and separated by comma  '1','2','b'</p>
  <p>So far this is the solution that I have:</p>
  <pre><code>declare @values nvarchar(max) = '1,2,a', @result nvarchar(max)
  
  set @result = (
      select REPLACE(@values, ',', '')
              )
  
  begin try    
      set @result = @result*1
      set @result = @values    
  end try 
  begin catch
      set @result = ( select ''''+ STRING_AGG( value, ''',''') + ''''
          from string_split(@values, ','))
  end catch
  
  select @result
  </code></pre>
  <p>Is it possible to reach the result without involving a try/catch block? (Request of the arquitect)</p>